Tutorial

Color Lab

Learn CSS color — formats (hex / rgb / hsl / oklch), palettes, gradients, accessibility, and creative effects like gradient text.

Color resources

Industry-standard tools for pickers, palettes, contrast, and inspiration — all free.

Palette Generator
Canva — Colors ↗

The best all-in-one hub. Palette generator, color wheel, color meanings, and palette ideas in one place.

Palettes
Coolors.co ↗

Press spacebar to cycle palettes. Lock colors you like. Export to CSS / Figma / Tailwind.

Contrast
WebAIM Contrast Checker ↗

The accessibility standard. Paste two colors, see if they pass WCAG AA / AAA.

Contrast
Who Can Use ↗

Shows how a color pair looks to users with different visual conditions (low vision, color blindness).

Color Names
W3Schools Color Names ↗

All 140+ CSS named colors in one table with hex values and live previews.

Tints & Shades
Make Tints & Shades ↗

Paste one hex, get 10 tints and 10 shades in a clean grid — copy hex values instantly.

Gradients
CSSGradient.io ↗

Visual gradient builder. Drag color stops, copy CSS. Linear, radial, and conic presets.

Inspiration
Huemint ↗

AI-generated brand palettes with live mockups. Great when you have zero ideas.

1. Color Formats — eight ways to write the same pink color
Hex#ec4899
RGBrgb(236 72 153)
HSLhsl(330 81% 60%)
OKLCHoklch(68% .24 10)
Alphargba(...50%)
Hex short#0b9 → #00bb99
color-mixpink + blue
Currentcolorinherits color
<div class="sw">Pink square</div>
/* Hex — 3 or 6 digits, optional alpha as 4th/8th */
.sw { background: #ec4899; }

/* RGB — integers 0-255, or percentages */
.sw { background: rgb(236 72 153); }
.sw { background: rgba(236, 72, 153, 0.5); } /* half transparent */

/* HSL — hue (0-360), saturation %, lightness % */
.sw { background: hsl(330, 81%, 60%); }

/* OKLCH — perceptually uniform, the modern choice */
.sw { background: oklch(68% 0.24 10); }

/* color-mix — blend two colors with a % */
.sw { background: color-mix(in srgb, #ec4899 60%, #3b82f6); }

/* currentColor — matches the element's color property */
.icon { fill: currentColor; }
2. Named Colors — 30 of the 140+ CSS keywords (see full list at w3schools ↗)
crimson#dc143c
tomato#ff6347
coral#ff7f50
salmon#fa8072
orange#ffa500
goldenrod#daa520
gold#ffd700
khaki#f0e68c
olive#808000
darkolivegreen#556b2f
forestgreen#228b22
mediumseagreen#3cb371
teal#008080
turquoise#40e0d0
skyblue#87ceeb
steelblue#4682b4
royalblue#4169e1
midnightblue#191970
slateblue#6a5acd
rebeccapurple#663399
indigo#4b0082
mediumorchid#ba55d3
orchid#da70d6
plum#dda0dd
hotpink#ff69b4
lightpink#ffb6c1
peachpuff#ffdab9
lavender#e6e6fa
seashell#fff5ee
dimgray#696969
/* CSS has 140+ named color keywords.
   Great for quick prototypes, worse for
   production where a design system is better. */

.btn    { background: tomato; }
.badge  { background: goldenrod; }
.heart  { color:      crimson; }
.ocean  { background: steelblue; }
.velvet { background: rebeccapurple; }

/* Fun fact: "rebeccapurple" was added to honor
   web-dev educator Eric Meyer's daughter Rebecca. */
3. Tints & Shades — nine steps from light → dark using HSL lightness

Pink (hue 330)

95
85
75
65
55
45
35
25
15

Blue (hue 220)

95
85
75
65
55
45
35
25
15

Green (hue 150)

95
85
75
65
55
45
35
25
15
/* HSL makes scale generation a one-liner:
   keep hue + saturation, step lightness */

.tint-95  { background: hsl(330 81% 95%); }
.tint-85  { background: hsl(330 81% 85%); }
.base-55  { background: hsl(330 81% 55%); } /* base */
.shade-25 { background: hsl(330 81% 25%); }

/* Even smarter: use CSS custom properties */
:root {
  --hue: 330;
  --sat: 81%;
}

.shade {
  background: hsl(var(--hue) var(--sat) var(--l, 55%));
}
.shade--soft { --l: 85%; }
.shade--deep { --l: 25%; }
4. Color Functions — mix two colors, add alpha, lighten / darken

color-mix — blend two colors

#ec4899
pink
+
#3b82f6
blue
color-mix(in srgb, pink, blue) = purple ✨

Alpha — half-transparent overlay

rgba(0,0,0,.3)
30% black
rgba(0,0,0,.6)
60% black
pink, 70%

Lighten & darken via color-mix with white / black

+40% white
(lighter)
base #ec4899
+40% black
(darker)
/* color-mix() — blend two colors in a given space */
.purple {
  background: color-mix(in srgb, #ec4899, #3b82f6);
}

/* Weight each color with a percentage */
.mostly-pink {
  background: color-mix(in srgb, #ec4899 80%, #3b82f6);
}

/* Add alpha by mixing with transparent */
.ghost {
  background: color-mix(in srgb, #ec4899 20%, transparent);
}

/* Lighten / darken by mixing with white / black */
.lighter { background: color-mix(in srgb, #ec4899 60%, white); }
.darker  { background: color-mix(in srgb, #ec4899 60%, black); }

/* rgba() for simple alpha — still widely supported */
.overlay {
  background: rgba(0, 0, 0, 0.5); /* 50% black */
}
5. Gradients — linear, radial, conic, multi-stop, and animated
linear-gradient(135deg)
3-color linear
radial-gradient (circle)
radial offset + base
conic-gradient (rainbow)
animated gradient
/* Linear — direction as angle or keyword */
.g1 { background: linear-gradient(135deg, #ec4899, #8b5cf6); }

/* Multi-stop — any number of colors */
.g2 { background: linear-gradient(90deg, #06b6d4, #10b981, #facc15); }

/* Radial — circle or ellipse, positioned anywhere */
.g3 { background: radial-gradient(circle, #ec4899, #1e1b4b); }

/* Offset radial + base color for a glow */
.g4 {
  background:
    radial-gradient(circle at 30% 30%, #f59e0b, transparent 60%),
    #1e1b4b;
}

/* Conic — sweeps around a center point */
.g5 {
  background: conic-gradient(from 0deg, #ec4899, #8b5cf6, #3b82f6, #10b981, #f59e0b, #ec4899);
}

/* Animated — shift background-position on an oversized gradient */
.g6 {
  background: linear-gradient(135deg, #ec4899, #8b5cf6, #3b82f6, #06b6d4, #ec4899);
  background-size: 300% 300%;
  animation: gradFlow 6s linear infinite;
}

@keyframes gradFlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
6. Contrast & Accessibility — WCAG ratios (aim for 4.5:1 body, 3:1 large)
AAA pass
Green background + white text
Contrast 4.53 : 1
AAA pass
Black on white is the gold standard
Contrast 21 : 1
Fails
Pale gold + light gray — too similar
Contrast 1.8 : 1
Fails
Light gray text on light gray
Contrast 1.4 : 1
Quick tools: Browser DevTools color picker shows contrast live. Online: webaim.org/resources/contrastchecker.
/* WCAG 2.1 minimums (AA):
   - Normal body text:  4.5 : 1
   - Large text (18pt+): 3 : 1
   - UI components:     3 : 1

   AAA is the stricter target:
   - Normal body text:  7 : 1
   - Large text:        4.5 : 1        */

/* Common pitfalls to avoid: */

/* ❌ Light gray text on white — hard to read */
.bad { color: #aaa; background: #fff; }

/* ✅ Darker gray passes AA on white */
.good { color: #555; background: #fff; }

/* ❌ Pure yellow on white — never has enough contrast */
.avoid { color: #ffd700; background: #fff; }

/* ✅ Yellow on dark background — lots of contrast */
.yellow-ok { color: #ffd700; background: #111; }

/* Don't rely on color alone — add icons, text,
   or patterns so colorblind users aren't lost.  */
7. Palettes — curated 5-color schemes for quick inspiration

Sunset— warm analogous

#f9a8d4
#f472b6
#ec4899
#be185d
#831843

Ocean— cool analogous

#bfdbfe
#60a5fa
#3b82f6
#1d4ed8
#1e3a8a

Duotone— complementary

#ec4899
#fce7f3
#ffffff
#d1fae5
#10b981

Editorial— warm neutrals

#fef6e4
#f3d2c1
#8bd3dd
#582c4d
#001858

Dark UI— high-contrast night mode

#0a0a14
#1e1b4b
#8b5cf6
#f59e0b
#f5f5f7

Forest— earthy, organic

#f2f5eb
#a8cf8e
#6a994e
#386641
#1e3a2a

Monochrome— single-hue elegant

#ffffff
#e5e5e5
#a3a3a3
#404040
#000000

Sorbet— vibrant triadic

#ffbe0b
#fb5607
#ff006e
#8338ec
#3a86ff

Terracotta— warm earth tones

#fef1e6
#e8a87c
#c38d9e
#85586f
#41393e

Pastel— soft muted tones

#fec5bb
#fcd5ce
#d8e2dc
#ffe5d9
#f4acb7
Need more palettes? Visit canva.com/colors, coolors.co, or colorhunt.co for thousands of curated palettes.
/* Good palettes have clear roles:
   - background / surface
   - primary (buttons, links)
   - secondary / accent
   - text
   - muted / border

   Store them as CSS custom properties: */

:root {
  --bg:         #0a0a14;
  --surface:    #1e1b4b;
  --primary:    #8b5cf6;
  --accent:     #f59e0b;
  --text:       #f5f5f7;
  --text-muted: #9ca3af;
  --border:     rgba(255,255,255,.08);
}

/* Inspiration: coolors.co, huemint.com, tailwindcss.com/docs/colors */
8. Creative Effects — gradient text, animated text, tinted images, neon glow

Gradient text — background-clip: text

Beautiful Pink Blue

Animated gradient text

Shifting rainbow headline

Tinted image — gradient overlay

Neon text glow — stacked text-shadow

GLOW
/* Gradient text — background-clip: text */
.grad-text {
  background: linear-gradient(135deg, #ec4899, #8b5cf6, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Tinted image — gradient overlay + image, stacked */
.tint-img {
  background:
    linear-gradient(135deg, rgba(236,72,153,.55), rgba(59,130,246,.55)),
    url('photo.jpg') center/cover;
}

/* Neon glow — multiple layered text-shadows */
.glow {
  color: #fff;
  text-shadow:
    0 0 8px #ec4899,
    0 0 20px #ec4899,
    0 0 40px #ec4899;
}

/* The same trick works for box-shadow too — see Box Lab */
9. Color Wheel — how hues relate (complementary / analogous / triadic / split)

Complementary — opposites

Two hues across the wheel. High contrast, high energy.

Analogous — neighbors

Three hues side by side. Harmonious, calm, cohesive.

Triadic — three evenly spaced

Three hues at 120° apart. Balanced yet vibrant.

Split-complementary — softer contrast

A base + two hues adjacent to its complement. High contrast with less tension.

/* Draw a color wheel with a single conic-gradient */
.wheel {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    hsl(0 90% 55%), hsl(60 90% 55%), hsl(120 90% 55%),
    hsl(180 90% 55%), hsl(240 90% 55%), hsl(300 90% 55%),
    hsl(0 90% 55%)
  );
}

/* Use HSL hue math to pick related colors:
   base + 180°       = complementary
   base ± 30°        = analogous
   base + 120°, 240° = triadic
   base + 150°, 210° = split-complementary */

:root { --base: 220; } /* blue */
.base  { background: hsl(var(--base) 80% 55%); }
.comp  { background: hsl(calc(var(--base) + 180) 80% 55%); }
.ana1  { background: hsl(calc(var(--base) - 30) 80% 55%); }
.ana2  { background: hsl(calc(var(--base) + 30) 80% 55%); }
10. Color Meanings — what each color evokes in branding (per Canva ↗)

Red — passion, urgency

Energy, excitement, appetite, love, danger. Demands attention — use sparingly.

Netflix · Coca-Cola · YouTube

Orange — friendly, playful

Warm, approachable, confident. Works well for creative and family brands.

Nickelodeon · Fanta · SoundCloud

Yellow — optimistic, cheerful

Sunshine, happiness, warmth. Hard to read as text — use as accent.

McDonald's · IKEA · Snapchat

Green — growth, nature

Health, money, balance, sustainability. Finance and wellness use it heavily.

Spotify · Starbucks · Whole Foods

Blue — trust, calm

Reliability, professionalism, stability. The most-used color in corporate branding.

Facebook · Twitter · LinkedIn · IBM

Purple — luxury, creative

Royalty, imagination, magic. Often used for beauty, wellness, and tech.

Twitch · Yahoo · Cadbury · Slack

Pink — playful, romantic

Feminine, youthful, fun. Trending in fintech and modern brands breaking conventions.

T-Mobile · Dunkin' · Barbie · Lyft

Brown — earthy, reliable

Natural, rustic, grounded. Used by coffee, chocolate, and outdoor brands.

UPS · Hershey's · Cracker Barrel

Black — bold, sophisticated

Power, elegance, timeless. The luxury fashion standard.

Nike · Chanel · Apple · Tesla
11. How to Make a Gradient — step-by-step from one color to a polished result
1

Pick two colors from the same temperature

Both warm (pink → orange) or both cool (teal → purple). Mixing temps tends to look muddy.

background: linear-gradient(90deg, #ec4899, #f59e0b);
2

Set an angle — 135° is almost always great

135° goes from top-left to bottom-right. It flatters most designs because light usually falls from above.

background: linear-gradient(135deg, #ec4899, #f59e0b);
3

Add a third stop for richness

Insert a middle color that sits between your start and end on the color wheel. Three-stop gradients feel more expensive than two-stop.

background: linear-gradient(135deg, #ec4899, #8b5cf6, #3b82f6);
4

Control color-stop positions

By default colors spread evenly. Push a stop closer to one edge to bias the gradient — here pink occupies 60%.

background: linear-gradient(135deg, #ec4899 30%, #8b5cf6 60%, #3b82f6);
5

Try radial for a spotlight effect

Change linear-gradient to radial-gradient. Adds depth, great for hero sections.

background: radial-gradient(circle at 30% 30%, #ec4899, #3b82f6);
6

Layer gradients for a mesh

Stack multiple radial gradients + a base color. This is the "Stripe-style" hero every site now uses.

background: 
  radial-gradient(circle at 20% 20%, #ec4899, transparent 50%),
  radial-gradient(circle at 80% 70%, #3b82f6, transparent 50%),
  #1e1b4b;
7

Visual builder — skip the math

Drag color stops on a canvas and copy the CSS output. cssgradient.io and mycolor.space/gradient are both great.