The three formats at a glance
| Format | Example | Dimensions | Best for |
|---|---|---|---|
| HEX | #267D70 | R, G, B (implicit) | CSS, design handoff, documentation |
| RGB | rgb(38, 125, 112) | R, G, B (explicit) | Alpha, programmatic manipulation |
| HSL | hsl(170, 53%, 32%) | Hue, saturation, lightness | Palette building, theming |
RGB — how screens think
RGB is the native color model of screens. Every pixel on every display emits red, green and blue light at three levels — usually 8 bits each, for 256 levels per channel. RGB values describe those three levels directly.
Use RGB when:
- You need alpha transparency —
rgba(38, 125, 112, 0.5)is more readable than 8-digit HEX. - You're manipulating channels programmatically — darkening a color by multiplying each channel by 0.8 is trivial in RGB.
- You're working with image data or canvas APIs, which natively use RGB.
Avoid RGB when:
- You want to reason about color relationships (hue rotation, saturation) — HSL is easier.
- You're writing compact documentation — HEX is more compact.
HEX — how CSS thinks
HEX is a compact notation for RGB. #267D70 and rgb(38, 125, 112) describe the same color — the HEX version is just shorter.
Use HEX when:
- You're writing CSS or HTML and need compact notation.
- You're documenting brand colors or design tokens.
- You're working in design tools that default to HEX.
Avoid HEX when:
- You need alpha and want it explicit —
rgba()is clearer. - You're programmatically generating colors — RGB or HSL is more natural.
HSL — how designers think
HSL re-expresses RGB as hue, saturation and lightness. Hue is measured in degrees around the color wheel, saturation as a percentage from gray to pure, lightness as a percentage from black to white.
Use HSL when:
- You're building palettes — changing only the lightness value produces a coherent tint or shade.
- You're rotating hue for complementary, analogous or triadic schemes.
- You're theming —
hsl(var(--brand-h) 80% 40%)makes brand hue a variable.
Avoid HSL when:
- You need perceptual lightness — HSL's lightness isn't perceptually uniform, so
hsl(60, 100%, 50%)looks brighter thanhsl(240, 100%, 50%)at the same lightness value. - You're doing exact color matching with an existing RGB or HEX value.
Conversion is exact
All three formats describe the same sRGB color space with 8 bits per channel, so conversion is exact and reversible for whole-number values. The only reason to worry about precision is when you're formatting to fewer decimal places, which can cause slight round-trip drift.
Practical recommendations
- Store your brand tokens in HEX — it's the most universally understood format for design documentation.
- Build your scale in HSL — reasoning about hue and lightness is easier than reasoning about three 0–255 values.
- Export to RGB when the value crosses into code that needs explicit alpha.
- Don't mix formats within the same concept — pick one representation per token and stick with it.