How Color Contrast is Calculated
Color contrast is measured by comparing the relative luminance of two colors — essentially, how much light each one reflects on a scale from 0 (pure black) to 1 (pure white).
The WCAG formula divides the lighter color's luminance plus 0.05 by the darker color's luminance plus 0.05, producing a ratio between 1:1 and 21:1.
A pure white background with pure black text scores the maximum 21:1, while identical colors score 1:1.
Each color's luminance is derived from its red, green, and blue channels after a gamma correction step that accounts for how human eyes perceive brightness.
This calculator handles that math automatically when you enter two hex values.