Sub topic 7
Color Contrast and Legibility
This chapter assumes you know basic typography terms (typeface, size, weight) and can read simple CSS. You have seen how contrast creates hierarchy through size, weight, and typeface. Here the focus is color: whether text can actually be read against its background.
Why color contrast is a legibility problem
Contrast through color only works if the two colors differ enough in lightness. Two colors can look very different in hue and still be hard to tell apart. Pale gray text on white and orange text on red are common examples. Hue alone does not carry a reading task. Lightness difference does.
Low contrast hurts more people than you might expect. It affects users with low vision, color-vision deficiency, and aging eyes. It also affects anyone reading a phone in sunlight, on a dim screen, or from across a room. A flyer printed on a low-quality printer loses contrast too.
Measuring contrast with the contrast ratio
The Web Content Accessibility Guidelines (WCAG) define a contrast ratio. It compares the relative luminance (perceived brightness) of two colors. The ratio runs from 1:1 (identical colors) to 21:1 (black on white).
| Content | Minimum ratio (WCAG AA) | Stricter target (WCAG AAA) |
|---|---|---|
| Normal body text | 4.5:1 | 7:1 |
| Large text (about 24px, or 18.66px bold) | 3:1 | 4.5:1 |
| Icons, input borders, and other UI parts | 3:1 | not specified |
Large text needs less contrast because bigger letterforms stay readable at lower contrast. Logos and purely decorative text are exempt from these minimums.
Here is the ratio formula:
(L1 + 0.05) / (L2 + 0.05)
L1 is the relative luminance of the lighter color and L2 is that of the darker color. You rarely compute it by hand. Figma plugins, browser developer tools, and online contrast checkers do it for you.
A worked example
The CSS below compares a failing and a passing text color on a white background.
.note {
background: #ffffff;
padding: 16px;
}
.note--weak {
color: #999999; /* about 2.8:1, fails AA for body text */
}
.note--strong {
color: #595959; /* about 7:1, passes AA and AAA */
}Both colors are gray, so they look like the same design choice. The first one fails because mid-gray on white sits near the lightness of the background. Darkening it to #595959 keeps the soft gray look and makes it readable.
Legibility is more than the ratio
A passing ratio is necessary but not sufficient. Several other choices affect whether text can be read:
- Size and weight. Thin weights lose contrast because the strokes are narrow and blend into the background. A light 300 weight needs a stronger color than a regular 400.
- Backgrounds with images. Text over a photo changes contrast from one word to the next. Add a solid overlay or a semi-transparent panel behind the text, then measure against the worst spot.
- Color pairs. Red and green can look alike to people with common forms of color-vision deficiency. Blue on red can vibrate visually.
- State changes. Disabled, hover, and focus states still need to be distinguishable from each other.
Dark text on light, light text on dark
Both polarities work if the ratio is high enough. Pure white text on pure black can cause a glare effect for some readers, especially in long passages. Many designers use an off-white such as #e8e8e8 on a very dark gray such as #121212. The ratio stays well above 7:1, and the page is easier on the eyes.
Common errors
- Checking only the headline and skipping small captions, placeholders, and footers.
- Judging contrast on your own bright monitor and never testing on a phone.
- Using opacity to soften text, which lowers the ratio without any visible warning in your design file.
- Passing the ratio with thin, small text that is still hard to read.
Exercise
A page has 16px regular body text in #8a8a8a on a white background, and the checker reports a ratio of 3.5:1. Does it pass WCAG AA, and what is one fix that keeps the same soft gray look?
Show answer
It fails. Body text at 16px regular is not large text, so it needs 4.5:1. Darken the gray, for example to #767676 or darker (about 4.5:1 or higher), and recheck. Increasing the size to large text would also lower the requirement to 3:1, but darkening the color is the simpler fix for body copy.
Exercise
An error message is shown in red with no other change from normal text. Name two ways to make it work for a reader who cannot distinguish red from the surrounding text.
Show answer
Add a non-color cue, such as an icon, a text label like "Error:", bold weight, or an underline. Also ensure the red meets the contrast ratio against its background.