How contrast is measured
WCAG 2.x defines contrast as (L1 + 0.05) / (L2 + 0.05), where L1 and L2 are the relative luminance of the lighter and darker color. The ratio ranges from 1:1 (identical colors) to 21:1 (black on white).
The thresholds
- AA, normal text: at least 4.5:1.
- AA, large text: at least 3:1. Large means 24 px, or 18.66 px bold, and up.
- AAA, normal text: at least 7:1; large text 4.5:1.
Beyond the number
Passing the ratio does not guarantee readability: font weight, size, anti-aliasing and the viewer's vision matter too. Use this as a floor, and test with real users where you can.