Skip to content

Text whose contrast needs checking by eye

a11y-color-contrast-reviewserious
On this page

Why it matters

  • Banners and offers often put text over photos and gradients, and that is often where contrast is lowest: a light word over a light part of the photo disappears.
  • WCAG 2.2's contrast requirement (1.4.3) holds for this text too, but tools cannot measure it reliably, so a person has to look.
  • This rule asks for a review only; it does not lower the score.

Example

Wrong
<p id="banner" style="color: #ffffff; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAEklEQVR4nGP4z8CAFWEXHbQSACj/P8Fu7N9hAAAAAElFTkSuQmCC); background-size: cover; padding: 24px">
  خصم على كل العطور هذا الأسبوع
</p>
Right
<p id="banner" style="color: #ffffff; background: #1d4d44; padding: 24px">
  خصم على كل العطور هذا الأسبوع
</p>

How to fix

  • Put a solid or semi-transparent layer between the image and the text, such as background: rgb(0 0 0 / 60%) behind white text.
  • Or move the text off the image, onto a plain background.
  • Check the text on a phone too, where the image may be cropped differently.

How we detect

  1. axe-core 4.13.0's color-contrast rule, run in each engine, reports text whose background it cannot determine: over an image, over a gradient, or behind another element.
  2. Each such text is listed for a person to check, with axe's reason: bgImage, bgGradient, bgOverlap and the like.