How to use it
Enter a text colour and a background colour as HEX codes or with the colour pickers. The tool computes the contrast ratio defined in WCAG 2 and checks it against the AA and AAA levels for normal text, large text and user-interface parts.
Each colour is converted to relative luminance. The sRGB channels are linearised (c / 12.92 when c is 0.04045 or less, otherwise ((c + 0.055) / 1.055) to the power 2.4) and combined as L = 0.2126 R + 0.7152 G + 0.0722 B. The ratio is (L1 + 0.05) / (L2 + 0.05), with L1 the lighter colour. It runs from 1:1 for two equal colours to 21:1 for black on white.
The thresholds are 4.5:1 for normal text at AA, 3:1 for large text at AA, 7:1 for normal text at AAA, 4.5:1 for large text at AAA, and 3:1 for user-interface parts and graphics. WCAG treats text as large from 18 point, or 14 point when bold. Suggest a passing colour keeps the hue and saturation of the text colour and moves its lightness until the pair reaches 4.5:1. The ratio is cut, not rounded, to two decimals, so a pair just under a threshold never reads as a pass. Avoid judging contrast by eye on a bright screen. Try the ratio first, then the preview.
Try this
- Check each text colour against every background it sits on.
- Use Swap to check light text on a dark band.
- Keep body text at 4.5:1 or more.
Questions
What contrast ratio does WCAG AA need?
4.5:1 for normal text and 3:1 for large text. AAA asks for 7:1 and 4.5:1.
How is the contrast ratio calculated?
From the relative luminance of each colour: (L1 + 0.05) / (L2 + 0.05), with L1 the lighter one. The full formula is on this page.
What counts as large text?
WCAG treats text as large from 18 point, or 14 point when bold. In CSS that is about 24 px, or about 18.7 px bold.
What does the suggested colour change?
Only the lightness of the text colour. Hue and saturation stay the same.
Does it matter which colour is the text?
Not for the ratio, which is the same both ways. The order only changes the preview.