Track 03 · Lesson 4 of 8Building for everyone
Track 03 · Building for everyone
Color contrast
Lesson 4 of 8· 7 min
Text needs enough contrast with its background to be readable in sunlight, on cheap screens and with low vision. WCAG measures it as a ratio from 1:1 (invisible) to 21:1 (black on white).
Measure it, then fix it
Try the presets and the vision filters
Common cases
The quick brown fox jumps over the lazy dog.
Buy nowServer status:APIDatabaseSee it like someone with…
2.99:1
Normal-size text: it needs at least 4.5:1 for level AA.
- AA for this text (4.5:1)Fail
- AAA for this text (7:1)Fail
- Buttons, borders and icons (3:1)Fail
Fails AA. Many people won’t be able to read this, especially outdoors or on a dim screen. Try “Fix the contrast for me”.
The numbers to remember#
- 4.5:1 for normal body text.
- 3:1 for large text: 24 pixels, or about 19 pixels when bold.
- 3:1 for the parts of controls you need to see: button edges, input borders, focus rings and meaningful icons.
The ratio comes from the relative luminance of the two colors, how bright each one is to the human eye. That's why yellow on white fails badly even though both look "bright and colorful": their luminance is almost the same.
Color alone is never enough#
Switch the preview to Deuteranopia. The green "API" dot and the red "Database" dot now look nearly the same, and one in twelve men sees them that way every day. Pair every color with something else: a label, an icon, a shape or a pattern. This site does it too: status always comes with a shape or a word.
Check yourself