Foreground × background — compute the WCAG contrast live and see at a glance whether AA / AAA passes.
A contrast ratio compares the relative luminance of two colours and is expressed as a range from 1:1 (identical) to 21:1 (black on white). It is calculated from the same luminance formula that drives WCAG, which weights the green channel far more heavily than red or blue because the human eye is most sensitive there.
Two useful anchors: pure black on pure white is 21:1, and mid-grey #767676 on white is exactly 4.54:1 — the lightest grey that still passes AA for body text.
| Level | Normal text | Large text | UI components |
|---|---|---|---|
| AA (minimum) | 4.5:1 | 3:1 | 3:1 |
| AAA (enhanced) | 7:1 | 4.5:1 | — |
"Large text" means 18pt (24px) regular, or 14pt (18.66px) bold and above. Icons, form borders and focus rings fall under the 3:1 UI component rule even though they are not text.
The cheapest repairs are usually to darken the text rather than lighten the background, to add a subtle text shadow over imagery, or to place text on a semi-transparent scrim. Raising font weight also helps: WCAG treats bold text as large from 14pt, which lowers the requirement from 4.5:1 to 3:1.