WCAG 2.1 contrast — how 4.5:1 is calculated
The WCAG 2.1 contrast thresholds are the most quoted numbers in web accessibility: 4.5:1 for body text, 3:1 for large text, 7:1 for AAA. The numbers are simple; the calculation is where mistakes happen, because contrast is not the difference in brightness but the ratio of relative luminance.
The formula
L = 0.2126·R + 0.7152·G + 0.0722·B
(R, G, B normalised to 0–1, then v ÷ 12.92 if v ≤ 0.03928, else ((v + 0.055) ÷ 1.055)^2.4)
ratio = (L lighter + 0.05) ÷ (L darker + 0.05)
The 0.05 keeps the ratio finite when one colour is pure black. Because of it, the same brightness difference produces a larger ratio at the dark end: black against grey beats white against grey.
| Level | Body text | Large text | Success criterion |
|---|---|---|---|
| AA | 4.5:1 | 3:1 | 1.4.3 Contrast (Minimum) |
| AAA | 7:1 | 4.5:1 | 1.4.6 Contrast (Enhanced) |
| Non-text | 3:1 | — | 1.4.11 Non-text Contrast |
“Large” means 18pt (about 24px) or 14pt (about 18.66px) at weight 700 and above. 16px body text is not large and needs 4.5:1. Treating bold 18px as large is a common mistake.
Where it goes wrong
- Text on a translucent background: ignoring alpha and compositing inflates the ratio.
- Text over gradients or images: both the lightest and the darkest point must pass.
- Status colours: colour alone fails colour-blind users even when contrast passes.
- Disabled controls: WCAG exempts them, but unreadable text is still unusable.
- Borders and icons: 1.4.11 asks for 3:1 on non-text elements too.
Where it applies
WCAG 2.1 AA underpins EN 301 549 in Europe and the Korean web accessibility guidelines, and the European Accessibility Act, applicable since June 2025, refers to WCAG 2.1 AA. So “the legal standard” is usually WCAG 2.1 AA. APCA is still a candidate for the WCAG 3 draft and is not a conformance test.
The contrast matrix here calculates all 121 pairs and badges 4.5:1, 7:1 and 3:1. Pairs that fail come with a lightness correction, so meeting the thresholds is not a manual loop of guesses.
A worked example makes the formula concrete. Take background #f7f7fb and text #1b1b22. The background has a relative luminance of about 0.94 and the text about 0.01, so (0.94 + 0.05) ÷ (0.01 + 0.05) = 16.5 — well past AAA. Swap the text for #8a8a96, luminance about 0.26, and the ratio falls to (0.94 + 0.05) ÷ (0.26 + 0.05) = 3.2: it clears large text but fails body text.
What that shows is how fast the ratio drops as a grey lightens. Choosing body colours with headroom, around 5.5:1 or more, keeps them compliant if the background shifts slightly later. The L-correction tool here targets 4.5 by default, and the same method reaches AAA when you ask for 7.
Clause numbers and thresholds follow the W3C WCAG 2.1 specification.
Questions
Does 4.5:1 mean I meet AA?
It meets the text contrast criterion. Full AA also covers focus indicators, keyboard access, alternative text and more.
Do icons need 4.5:1?
Icons are non-text, so 3:1 applies. If an icon is the only carrier of information, higher contrast is advisable.
Why does another tool give a different number?
Usually background compositing or colour-space conversion. This tool uses the 8-bit sRGB values directly, so it matches a hex calculation.
Check all 121 pairs of your palette in the contrast matrix.
Open the toolBasis date 28 November 2026. Written against the W3C specifications, the APCA documentation and published browser support tables; updated when they change.
Back to the guides