Text over a photo: how to pass WCAG contrast (and why checkers miss it)
Normal text needs 4.5:1 against what's behind it, large text (24 px, or 18.66 px bold) 3:1, and buttons and other controls 3:1 against their surroundings. On a photo, measure against the lightest pixels behind dark text (or the darkest behind light text), not the photo's average. Fixes that keep the photo: a gradient scrim behind the text, a solid panel, a darker or blurred crop, or moving the text off the busy part.
The details
| What | Minimum contrast | WCAG criterion |
|---|---|---|
| Normal text | 4.5:1 | 1.4.3 (AA) |
| Large text: ≥ 24 px, or ≥ 18.66 px bold | 3:1 | 1.4.3 (AA) |
| Buttons, inputs, focus rings, icons that carry meaning | 3:1 | 1.4.11 (AA) |
| Logos and decorative text | No requirement | 1.4.3 |
Source: w3.org/WAI/WCAG22/Understanding/contrast-minimum.html and non-text-contrast.html.
What usually goes wrong
- Checking the text colour against the photo's average colour: the bright patch behind one word fails.
- A hero that passes on desktop but fails on a phone, where the crop puts the sky behind the headline.
- Light text on a light photo with a text-shadow that only helps a little.
- Text that fades in: checkers read it at its starting opacity, people at its end.
What your agent can't do alone
Palm's a11y-check (free) measures contrast against the actual rendered pixels behind each line of text, at phone and desktop size, so text over photos and gradients is checked the way people see it.
Questions
What contrast ratio does WCAG AA need?
4.5:1 for normal text and 3:1 for large text (24 px, or 18.66 px bold) and for controls.
How do I check contrast of text on an image?
Measure against the worst pixels behind the text, at the size and crop people see, or add a scrim so the background under the text is even.