Good to know
How the ratio is worked out
WCAG 2.x compares the relative luminance of the two colours. Each sRGB channel (0 to 255) is scaled to 0 to 1 and linearised, then the three channels are weighted by how bright they look to the eye:
c = value ÷ 255 linear = c ÷ 12.92 when c ≤ 0.04045 linear = ((c + 0.055) ÷ 1.055)^2.4 otherwise L = 0.2126 × R + 0.7152 × G + 0.0722 × B ratio = (L1 + 0.05) ÷ (L2 + 0.05)
L1 is the luminance of the lighter colour and L2 that of the darker one, so the ratio runs from 1:1 (two identical colours) to 21:1 (black on white).
A worked example
Grey #777777 has 119 in each channel. 119 ÷ 255 = 0.4667, which linearises to 0.1845, so L = 0.1845. Against white (L = 1): (1 + 0.05) ÷ (0.1845 + 0.05) = 4.48. That fails AA for normal text by a hair. One step darker, #767676, gives 4.54 and passes. The checker compares the unrounded figure with each threshold and never rounds a failing result up to 4.50, so a pass on screen is a real pass.
Which threshold applies
| Use | AA | AAA |
|---|---|---|
| Normal text | 4.5:1 | 7:1 |
| Large text: 24px, or about 18.66px bold | 3:1 | 4.5:1 |
| Icons, input borders, focus rings | 3:1 | no higher level |
The text rows come from WCAG 2.2 success criteria 1.4.3 (Contrast, Minimum) and 1.4.6 (Contrast, Enhanced). The row for interface parts is 1.4.11, Non-text Contrast. Large text means at least 18pt, or 14pt bold, which is 24px or about 18.66px on screen.
Limits
- Only solid hex colours are checked. For a semi-transparent colour, check the colour you actually see once it is blended with what sits behind it.
- Text over a photo or a gradient changes contrast from spot to spot. Check the lightest and the darkest areas behind the words.
- The ratio is a minimum, not a promise. Very thin fonts and tiny sizes can still be hard to read at a passing ratio.