Colour tools — color tools in American spelling — convert between the notations browsers accept and check whether a pairing is actually readable. The second job matters more: contrast failures are the single most common accessibility problem on the web, and they are entirely preventable at design time.
The notations
| Format | Example | Good for |
|---|---|---|
| HEX | #3B82F6 | Compact, universally supported |
| RGB | rgb(59 130 246) | Programmatic manipulation |
| HSL | hsl(217 91% 60%) | Building palettes by adjusting one value |
| HEX with alpha | #3B82F680 | Transparency in a compact form |
| OKLCH | oklch(0.62 0.19 259) | Perceptually even lightness steps |
HSL is the practical choice for building a palette by hand: hold hue and saturation constant, vary lightness, and you have a coherent scale. The catch is that HSL lightness is not perceptual — hsl(60 100% 50%) (yellow) looks far brighter than hsl(240 100% 50%) (blue) at the same stated lightness. OKLCH fixes this, which is why design systems are increasingly built on it.
Contrast ratios
Contrast is the ratio between the relative luminance of two colours, from 1:1 (identical) to 21:1 (black on white).
| Content | WCAG AA | WCAG AAA |
|---|---|---|
| Body text | 4.5:1 | 7:1 |
| Large text (18pt+, or 14pt bold) | 3:1 | 4.5:1 |
| UI components, focus indicators, icons | 3:1 | — |
The failures that recur most: light grey placeholder text, white text on mid-tone brand colours, and disabled states so faint they cannot be read at all. Note that contrast is calculated from luminance, not from how different two colours look — two colours of similar lightness but opposite hue can look distinct and still fail badly.
Do not rely on colour alone
Around 8% of men and 0.5% of women have some form of colour vision deficiency, most commonly difficulty distinguishing red from green. A form marking errors only in red, a chart distinguishing series only by hue, or a status dot with no label all fail for those users. Add an icon, a label, a pattern or a text cue alongside the colour — this costs almost nothing and is one of the highest-value accessibility habits available.
Building a usable palette
- Choose one primary colour.
- Generate a scale by varying lightness in even perceptual steps — typically nine or ten shades.
- Check which shades pass 4.5:1 against your background, and use only those for text.
- Add semantic colours for success, warning, error and information, and check each against the surfaces it appears on.
- Define neutrals separately; slightly tinting greys toward your primary hue makes an interface feel more coherent.
Dark mode is not an inversion
Inverting a light palette produces harsh, over-saturated results. Pure white text on pure black causes halation and eye strain for many readers. Prefer a very dark grey background with a slightly off-white text colour, desaturate accent colours a little, and re-check every contrast pairing — a colour that passes on white frequently fails on a dark surface.