- WCAG 2.x AA needs 4.5:1 for normal text and 3:1 for large text.
- Large means at least 24px regular, or about 18.66px bold.
- Measure against the lightest or darkest area behind the text, never the average.
- A scrim gradient is the most reliable fix. Recheck every crop that cover produces.
The numbers that apply
WCAG 2.x success criterion 1.4.3, Contrast (Minimum), sets the AA level most teams target. Contrast ratio runs from 1:1, the same color, to 21:1, black on white.
| Content | AA | AAA |
|---|---|---|
| Normal text | 4.5:1 | 7:1 |
| Large text | 3:1 | 4.5:1 |
| UI components and meaningful graphics | 3:1 | Not defined |
Large text is at least 18 point, which is 24 CSS pixels, at regular weight. Bold text counts as large from 14 point, about 18.66 CSS pixels. A 20px regular heading is not large text. It needs 4.5:1.
The 3:1 rule for interface parts comes from criterion 1.4.11, Non-text Contrast. It covers buttons, input borders and focus indicators. When a button sits on a photo, its boundary needs 3:1 against the image around it.
Logos and purely decorative text are exempt. Everything a visitor has to read is not.
Measuring contrast over an image
A contrast checker needs two colors. An image gives you thousands. The rule is simple: measure against the worst case. For light text, find the lightest pixels behind the letters. For dark text, find the darkest.
A practical routine:
- Take a screenshot of the real page, with the text in place.
- Zoom into the area behind each line of text.
- Sample the lightest or darkest spot that touches a letter.
- Check that color against the text color.
- Repeat for each breakpoint, because the image moves under the text.
Averages lie. A dark photo with a few bright highlights can average out to a safe value while one word sits on a highlight and disappears. Bokeh is the classic case. The night city bokeh background is mostly dark, but its amber and blue circles are bright enough to swallow white text that crosses them.
How the ratio is calculated
The ratio compares relative luminance, not hue. Each color gets a luminance value between 0 for black and 1 for white. The ratio is the lighter value plus 0.05, divided by the darker value plus 0.05. Because hue is ignored, saturated pairs like red on green can look strong and still fail.
Do not trust your eye here. A tool that reads exact pixel values is faster and more honest. Your browser's developer tools include a color picker that reports the ratio for a text color against a chosen background.

Scrim gradients
A scrim is a semi transparent layer between the image and the text. It lowers the range of brightness under the letters, so the worst case becomes predictable. It is the most reliable fix, because it works no matter how the image crops.
.hero {
background:
linear-gradient(to top, rgb(0 0 0 / 0.7) 0%, rgb(0 0 0 / 0.35) 45%, rgb(0 0 0 / 0) 75%),
url("city.jpg") center bottom / cover no-repeat,
#10213d;
color: #fff;
}Place the dark end where the text sits. A headline at the bottom of a hero needs the scrim at the bottom. Text on the left needs a gradient that runs to right.
Some tips for good scrims:
- Use several color stops. A two stop linear gradient shows a visible edge where it ends.
- Tint the scrim with a dark color from the image instead of pure black. It looks more natural.
- For dark text, use a light scrim. The same logic applies in reverse.
- Measure the result, not the intent. A 40% black layer does not guarantee 4.5:1 on its own.
A solid panel behind the text is the strict version of a scrim. It is the safest choice for long text, forms and anything a visitor must read in full.
What text-shadow can and cannot do
A soft text-shadow is a popular quick fix. It helps a little, but it is not reliable on its own.
WCAG measures contrast between text and the colors next to it. A thin, blurred shadow does not create a consistent edge around each letter, so the measurable background is still the image. Across a busy photo, some letters get a usable halo and others do not.
A dense outline, built from several shadows with no blur, comes closer. It creates a solid ring of color around the glyphs, and that ring can serve as the background for the contrast check. The cost is visual: outlined text looks heavy and can read as dated.
Use text-shadow to smooth out small variations after a scrim has done the main work. Do not use it as the only guarantee of contrast.
Blurring the image itself helps in the same supporting way. A blur removes fine detail behind the letters, so edges compete less with the glyph shapes. It does not change brightness, though, so the ratio still has to pass.

Respecting prefers-contrast
Some visitors ask their operating system for more contrast. CSS exposes this through the prefers-contrast media feature. Its value more is a direct signal to remove decoration that competes with text.
@media (prefers-contrast: more) {
.hero {
background: #0a0a0a;
color: #ffffff;
}
}You do not need to drop the image for everyone in this mode. Strengthening the scrim or switching to a solid panel behind the text is often enough. Keep focus outlines and button borders clearly visible in the same block.
Also remember text that has no image behind it in some states. If the image fails to load, the text sits on the background-color. Choose a color that passes contrast with your text on its own.
The same applies while the image is still downloading. On a slow connection, visitors may read the headline for a second or two before the photo appears. A fallback color close to the image's dark tone keeps the text readable and makes the swap less jarring.
Test at every crop
background-size: cover crops a different part of the image at each width. A headline that sits on dark sky at 1440 px wide may sit on a bright building at 375 px. Text also reflows, so a line that was short on desktop wraps and spreads across more of the image on mobile.
Check at least these widths:
- 320 and 375 px for small phones
- 768 px for tablets in portrait
- 1280 and 1440 px for common laptops
- 1920 px or wider, where the image scales up the most
Images with even tone are easier to work with. A city landscape background has a calm gradient sky above the skyline, which gives text a stable area when you anchor it with center bottom. The old paper set works the other way, with dark text on a light surface, but its burnt edges are darker than the center. Keep text away from the edges or add a light scrim. For more calm options, look at background textures.


