A11yDen

Home / Guides

Contrast ratios explained

A contrast ratio compares the brightness of text with the brightness of what sits behind it. It is the single most checked number in web accessibility — and one of the most misunderstood, because the ratio alone does not tell you whether you pass. The text's size, its weight, and what kind of thing it is all change the requirement. This guide explains the rules exactly as WCAG 2.2 states them, and the traps that catch people out.

How the ratio is calculated

WCAG defines contrast as (L1 + 0.05) / (L2 + 0.05), where L1 is the relative luminance of the lighter colour and L2 the relative luminance of the darker one. Relative luminance is a weighted measure of a colour's brightness, calculated from its red, green and blue components after linearising them. The scale runs from 1:1 (a colour against itself — invisible) to 21:1 (black on white). You never need to do this arithmetic by hand; a checker does it. What matters is knowing which threshold applies to your text.

The thresholds: AA and AAA

TextAA (SC 1.4.3)AAA (SC 1.4.6)
Normal text4.5:17:1
Large text3:14.5:1

AA is the level most laws, procurement rules and organisational policies point at. AAA is a stricter target worth aiming for on body text where the design allows it, but WCAG itself does not recommend requiring AAA across a whole site.

What counts as "large text"

WCAG's definition is precise: large-scale text is at least 18 point, or at least 14 point and bold. In the pixels CSS uses, that is roughly 24px for regular text and 18.7px for bold text. A 20px headline in a light font weight is still "normal text" under the rules and needs 4.5:1, however big it looks on your screen. When in doubt, test against the stricter threshold.

What the ratio does not cover

Three exemptions and one neighbour rule matter in practice:

The rounding trap

A ratio of 4.499:1 fails the 4.5:1 requirement — but many tools display it rounded up as "4.5" beside a green tick. That is a fail wearing a pass's clothing. A11yDen's tools always judge on the unrounded ratio and truncate the displayed figure, so a displayed 4.5 can only ever be a real pass. Whichever checker you use, ask yourself whether you know its rounding behaviour; if you cannot find out, treat borderline results as failures and adjust the colour.

A practical checking routine

  1. List every text/background pairing on the page, including hover, focus and selected states — states have to pass too.
  2. For text over photographs or gradients, sample the lightest and darkest points behind the actual glyphs and judge the worst one.
  3. Check component boundaries and icons against the 3:1 non-text rule.
  4. When a pairing fails, adjust the colour rather than arguing with the threshold — small moves in lightness usually fix it while keeping the hue.

Put it into practice

Sources and checking

WCAG facts in this guide follow the official W3C WCAG 2.2 Recommendation and its Understanding documents; any other fact is attributed to its source in the text. Facts checked November 16, 2026. Direct links to the sources are in the references below.

References

More guides