Skiplink

Guides

Fixing color-contrast violations, and why some need review

Low contrast is the most common detectable problem on the web, and usually the cheapest to fix: one design token, changed once. Here is what the rule measures and where it has to give up.

What the rule checks

axe-core's color-contrast (opens in a new tab) rule tests visible text against WCAG 2.2 success criterion 1.4.3 Contrast (Minimum) (opens in a new tab), at level AA. It computes the foreground colour of each text node, works out the background behind it, and compares the two as a contrast ratio between 1:1 (no difference) and 21:1 (black on white).

The thresholds:

Text that is part of an inactive control, purely decorative, invisible, or part of a logo is exempt. Disabled form controls are the case you will meet most often.

A typical result looks like this:

{
  "rule": "color-contrast",
  "impact": "serious",
  "wcag": ["1.4.3"],
  "selector": ".hero__subtitle",
  "message": "Contrast ratio 3.03:1, needs 4.5:1"
}

Close is not a pass

The ratio is a hard line. The classic example is #777777 on white: 4.48:1, which fails for body text. #767676, one step darker, is 4.54:1 and passes. Nobody can see the difference between those two greys, which is exactly why a tool is better at this check than a person squinting at a mock-up.

/* Before: 4.48:1 on white, fails for normal text */
.meta { color: #777; }

/* After: 4.54:1, passes */
.meta { color: #767676; }

Some other common pairs on a white background:

ColourRatio on whiteNormal textLarge text
#9999992.85:1FailsFails
#9494943.03:1FailsPasses
#6b72804.83:1PassesPasses
#5959597.0:1PassesPasses

Buttons are the other common source: white text on a mid-blue such as #3b82f6 is 3.68:1, fine for a large heading and a failure for a 16px button label. #2563eb is 5.17:1.

Fix the token, not the element

Contrast failures cluster. A grey defined once in a design system and used in forty places produces forty violations and needs one fix. Before you touch any CSS, sort the findings by colour pair and you will usually find three or four values responsible for nearly all of them.

When the brand colour itself cannot change, change what sits next to it: darken the text, put the text on a solid panel, or reserve the brand colour for large text and non-text decoration where 3:1 or no requirement applies. Making text bigger only helps if it crosses the large-text threshold.

Why some results say "needs review"

axe-core sorts results into more than pass and fail. When it cannot work out the background colour with confidence, it reports the element as incomplete, meaning a person has to decide. The usual reasons:

These are not violations, so a gate that fails on violations will not fail on them. That is the correct behaviour: failing a build on a guess would be wrong half the time. It also means a hero banner with text over a photograph can pass a scan and be unreadable. Check those by hand, at the narrowest and widest viewport, since the crop of the image changes.

A common fix for text on images is a solid or semi-opaque scrim behind the text. It gives the text a predictable background, which helps both readers and the rule.

What the rule does not cover

Keeping it fixed

Contrast regressions come back with every new component and every marketing page. Once you have fixed the tokens, a CI check that fails on new violations stops the forty-first low-contrast label from merging. The criteria table shows which perceivable criteria a scan can and cannot see, and what a scan does not tell you covers the rest.

Try it on your own site: scan a URL for free, or read the docs to add a baseline to your pipeline.