WCAG contrast levels
The Web Content Accessibility Guidelines (WCAG) set minimum contrast ratios between text and its background, so that people with low vision or colour blindness can read it:
| Level | Ratio needed | Where it applies |
|---|---|---|
| AA, normal text | 4.5 : 1 | Body text, captions, labels and text in input boxes. |
| AA, large text | 3 : 1 | Text at least 18pt (24px), or bold text at least 14pt (about 18.7px). |
| AAA, normal text | 7 : 1 | The stricter level, for the easiest reading. |
| AAA, large text | 4.5 : 1 | Large text at the stricter level. |
| Parts of the page you use | 3 : 1 | Input borders, button outlines, focus rings and icons that carry meaning. |
Most websites aim for level AA.
How the contrast ratio is calculated
The ratio goes from 1:1 (the same colour twice) to 21:1 (black on white). Green counts for most of the brightness because our eyes are most sensitive to it.
Worked examples
The two greys look almost the same, but only the darker one passes AA for body text. That's why it's worth checking the numbers instead of trusting your eyes.
How to fix a colour that fails
- Darken the text or lighten the background (or the other way round on a dark background) until the ratio passes. Small changes are often enough.
- Make the text bigger or bold if it's a heading. Large text only needs 3:1 for AA.
- Check every state, not just the normal one: links, hover and focus colours, disabled buttons that still need to be read, and placeholder text.
- Check text on pictures against the lightest and darkest parts of the picture behind it, or add a solid background behind the text.
- Don't use colour alone to show meaning, such as red for an error. Add words or an icon too.
Frequently asked questions
Do I have to meet WCAG?
WCAG is the standard most accessibility rules and guidance point to, and level AA is the usual target. Whether it's a legal requirement for your website depends on your country and what kind of organisation you are, so check the guidance that applies to you. Either way, good contrast makes your site easier for everyone to read, for example on a phone in bright sunlight.
Do logos need to pass?
No. WCAG makes an exception for logos and brand names, and for text that's purely decorative or part of a picture that isn't meant to be read.
What about dark mode?
Check both themes. A colour that passes on a white background can fail on a dark one, so test each pair of text and background colours you actually use.
Source: W3C: Web Content Accessibility Guidelines (WCAG) 2.2.