How WCAG contrast ratio is calculated and what it measures
The WCAG contrast ratio formula converts each color to relative luminance — a value between 0 (absolute black) and 1 (absolute white) — using a linearization of the sRGB values followed by luminance weighting that matches the human eye's sensitivity (more sensitive to green than red than blue). The contrast ratio between two colors is then (brighter luminance + 0.05) / (dimmer luminance + 0.05). This formula measures luminance contrast, not color difference. Two colors that are perceptually very different (a saturated red and a saturated green) can have low contrast ratios if their luminance values are similar. This is why red-green combinations are accessibility problems — not because the colors are too similar to distinguish for color-sighted users, but because many users with color deficiencies cannot distinguish red from green, and the luminance contrast between them is often insufficient to compensate.
