contrast-computable

Color contrast is computable for rendered text

automaticWCAG 1.4.3, 1.4.6 (AAA)confidence: highseverity: seriousperceivable

Determines whether sufficient information is available to compute WCAG color contrast for visible text (e.g., no gradients/images/blend modes that make background indeterminate).

Applies to. Applies to every visible text node in scope, plus the label of <input type="button">/[type="submit"]/[type="reset"], which is rendered from the value attribute and so is invisible to a text-node walk. Text counts only when its element is DOM-visible under the run's visibility mode, is not clipped out of sight by the sr-only technique (clip or clip-path), and belongs neither to a disabled control nor to the label of one, WCAG's inactive-user-interface-component exception. Subtrees excluded via engineOptions.excludeSelectors are skipped, and open shadow roots are walked as roots in their own right.

Expectation. Both sides of the contrast calculation can be established from CSS for every applicable text node: an effective background resolving to an opaque color, and a parsable foreground color. Where either cannot be, a background image or gradient, mix-blend-mode, a filter or backdrop-filter, a text-shadow (which may add contrast this engine has no glyph-rendering model to account for), ancestor opacity, a root background that never becomes opaque, or a color that does not parse, the result is cantTell naming the blocker. This rule is the one that reports that uncertainty, which is what lets contrast-minimum and contrast-enhanced stay silent on the same text instead of guessing at a ratio.

Examples

pass
<p style="background:#ffffff; color:#999999;">Body text</p>

Foreground and background are both flat, opaque colors, so a ratio can be computed (whether or not it later passes AA/AAA).

can't tell
<p style="background-image:url(texture.png); color:#000000;">Body text</p>

A `background-image` behind the text is not a flat color, so no contrast ratio can be computed at all.

View source