A white headline can look crisp on the desktop crop of a landscape and disappear into the sky on mobile. Sampling the average color of the photograph hides the failure. Test the brightest area that can actually sit behind a letter.
Use a white test card first
For white text over an ordinary photograph, temporarily replace the photograph with solid white. A 50% black overlay over white produces roughly #808080, giving only about 3.95:1 against white text. At 60% black the result is #666666, about 5.74:1. Enter those two foreground/background pairs into the contrast checker to reproduce the difference.
.hero { background-image: linear-gradient(rgb(0 0 0 / 60%), rgb(0 0 0 / 60%)), var(--photo); color: white; }
Put the overlay in the background layers. Applying opacity to the entire hero also fades the headline. The example assumes ordinary compositing, opaque white lettering and a uniform overlay.
Restore the photo and change the crop
- Check the narrow layout with the longest headline. Watch where the second line wraps.
- Disable the photo. Set a dark fallback background so a failed image request still leaves legible text.
- If the overlay obscures an important subject, place the headline on a solid panel below the photo. Verify the actual panel and text pair again.
For text-size exceptions and the definition of contrast, see WCAG minimum contrast.
