harmmy

WCAG contrast: the ratio, AA and AAA thresholds, and traps

How contrast ratio is computed, what AA and AAA require, and why a color picker alone misses gradients, opacity and images.

2026-12-02

What the ratio actually measures

Contrast ratio is a single number between 1:1 and 21:1. Take the relative luminance of the lighter colour and of the darker one, add 0.05 to each, and divide: (L1 + 0.05) / (L2 + 0.05). Pure white on pure black lands at 21:1, two identical colours at 1:1. The 0.05 keeps a black pixel from dividing by zero and keeps very dark pairs finite.

Luminance is not the average of R, G and B. Each sRGB channel is divided by 255, then linearised: values up to 0.04045 are divided by 12.92, above that they take the (c + 0.055) / 1.055 shift and a 2.4 power. The results are weighted 0.2126 red, 0.7152 green, 0.0722 blue. Green dominates, which is why a saturated green can look bright and still score poorly against white.

AA and AAA thresholds, and the large-text exception

AA asks 4.5:1 for normal text and 3:1 for large text. AAA raises those to 7:1 and 4.5:1. Large means at least 18pt regular or 14pt bold, roughly 24px and 18.66px, measured on the rendered font size rather than the line box.

The exception is narrower than people assume. A 24px heading in a light weight still counts as large; a bold 17px label does not, because bold starts at 14pt (about 18.66px). Review templates vary, and WCAG revisions and national rules change, so check the official specification current at the time of your audit. Grey #777 on white is the classic near miss at about 4.48:1, just under AA.

The 3:1 rule for icons, borders and focus rings

Success criterion 1.4.11 extends 3:1 past text to the parts of an interface you have to perceive: input borders, toggle tracks, icon buttons, and the focus indicator. A grey 1px border at 2:1 may be visible to you and invisible to someone with low vision or a washed-out laptop outdoors.

Two caveats. The 3:1 applies to the visual boundary against adjacent colours, so a border must contrast with the background it sits on, not with the text inside. And an element that also has a clear label or shape may not need the border at all; the requirement targets information carried by the graphic itself. Purely decorative dividers are out of scope.

Where the picker fails: gradients, opacity, images

A colour picker samples one pixel. Text over a photo, a gradient button, or a 60% opaque caption sits on many backgrounds at once, and the ratio changes across the element. Sample the worst point, or add a solid scrim behind the text so one value applies everywhere.

Opacity compounds the error: white text at 50% over black is grey, and tools that report the raw hex ignore the blend. Antialiasing and subpixel rendering soften edges, and two monitors with different gamma can make a passing pair look thin. Use the computed ratio as a gate, then look at the rendered result on a real screen.

Put contrast into the workflow, not a final check

Decide contrast in tokens, not page by page. Fix a small palette of text-on-background pairs that pass, then apply them to components; retrofitting individual screens after launch is where regressions creep in. Our contrast checker reports the ratio and the four AA/AAA results for a pair and suggests the nearest shade that reaches 4.5:1, so you can correct a token before it spreads.

Treat AA as a floor, not a legal shield. It does not cover users who rely on hue alone (1.4.1), and disabled controls, logos and incidental decoration are exempt, which is easy to over-apply. Checking every new colour pair, and rechecking after a theme change, catches far more than a single audit at the end.

Related tools

WCAG contrast: the ratio, AA and AAA thresholds, and traps | harmmy