← Back to the Color Lab
Lesson

Color, Visually

Color is the fastest way to make a page feel intentional — or chaotic. This visual lesson covers how screens make color, every CSS format, building a palette, color schemes, contrast for accessibility, and gradients, with live swatches and a color mixer you can drag.

Step 1

How screens make color

A screen mixes light, not paint. Every pixel blends three lights — red, green, blue (RGB). All three off is black; all three full is white. That's the opposite of paint, where mixing everything gives a muddy dark.

R only · red
G only · green
B only · blue
R+G · yellow
G+B · cyan
R+G+B · white
Every CSS color format below is just a different way of writing down how much red, green, and blue to mix — plus, sometimes, transparency.
Step 2

The CSS color formats

FormatExampleBest for
NamedtomatoQuick tests. ~140 keywords, limited.
Hex#2997ffThe everyday default; what pickers give you.
rgb()rgb(41 151 255)When you're thinking in red/green/blue, or need alpha.
hsl()hsl(212 100% 58%)Tweaking by hand — nudge lightness for hover states.
oklch()oklch(70% .15 250)Modern, perceptually even palettes (newer browsers).
They're interchangeable. #2997ff, rgb(41 151 255), and hsl(212 100% 58%) are the exact same blue — pick the format that's easiest to reason about for the job.
Step 3

Hex codes, decoded

A hex color is #RRGGBB — three pairs giving the amount of red, green, blue. Each pair runs 00 (none) to ff (full), which is 0–255 in everyday numbers.

29
Red · 41
97
Green · 151
ff
Blue · 255

#2997ff = a little red, medium green, full blue → a bright sky blue.

Shortcut: #fff is shorthand for #ffffff (white) and #000 for black — when each pair is doubled, you can write it once.
Step 4

HSL: the format you can think in

HSL describes color the way people do: Hue (which color, 0–360° around the wheel), Saturation (how vivid, 0–100%), Lightness (how bright, 0–100%). Drag the sliders:

hsl(280 80% 60%)
Why designers love it: keep hue and saturation fixed, lower the lightness, and you instantly have a darker shade for a hover or border — a built-in palette from one color.
Step 5

Building a usable palette

A site doesn't need 20 colors. A solid starter palette is one brand color, a neutral ramp (your grays), and one accent for calls-to-action.

Brand · #6d28d9
Ink · #0f172a
Muted · #475569
Line · #e2e8f0
BG · #f8fafc
Accent · #f59e0b
The 60-30-10 rule: ~60% a dominant/neutral color, ~30% a secondary, ~10% a bold accent. The accent is rare on purpose — that's what makes a button pop.
Step 6

Color schemes from the wheel

Harmonious palettes come from fixed relationships on the color wheel. Pick one hue, then derive the rest:

Complementary

Opposite hues. High contrast, energetic.

Analogous

Neighbors. Calm, cohesive.

Triadic

Three evenly spaced. Vivid, balanced.

Monochromatic

One hue, varied lightness. Elegant.

Don't want to eyeball it? The Color Lab links out to generators like Coolors and Canva that build these schemes for you — but knowing the names tells you why a palette works.
Step 7

Contrast & accessibility

Color choices decide whether people can read your text. WCAG sets a minimum contrast ratio of 4.5:1 for normal text (3:1 for large text). Compare:

Readable text on dark#f8fafc on #0f172a → 16.1:1 ✓ passes
Hard-to-read low contrast#64748b on #475569 → 1.6:1 ✗ fails
Never rely on color alone. ~1 in 12 men can't distinguish red from green. Pair color with a label, icon, or underline — e.g. an error needs an “Error:” word and an icon, not just red text.

Check any pair with a contrast tool (WebAIM, or the Color Lab's resources) before shipping.

Step 8

Gradients

A gradient blends two or more colors. linear-gradient() goes in a direction; radial-gradient() spreads from a point. They're values, so they go anywhere a color does — usually background.

linear 90deg
linear 135deg
radial
3-stop
.hero { background: linear-gradient(135deg, #ec4899, #8b5cf6); }
For gradient text (like this lesson's title), set the gradient as the background, then clip it to the text: background-clip: text; -webkit-text-fill-color: transparent;
Step 9

Transparency & alpha

Add an alpha channel to make a color see-through — great for overlays, tints, and soft shadows. 0 is invisible, 1 is solid.

alpha 1.0
alpha .6
alpha .3
alpha .1
background: rgb(236 72 153 / .3);   modern syntax
background: rgba(236, 72, 153, .3); classic, still fine
background: #ec489933;          hex with alpha (last 2 digits)
Common use: a subtle tinted border or background like rgba(255,255,255,.08) — the soft card outlines throughout this site are exactly that.
Step 10

Color checklist

Where next

Keep going