Guides / 02—08
Why relative luminance determines contrast
Text and background contrast uses relative luminance, not raw differences between HEX numbers.
Transform channels before weighting
In the WCAG formula, sRGB channels are normalized to 0–1 and linearized. Small channel values are divided by 12.92; other values use a 2.4 power. Relative luminance combines linear red, green and blue with weights 0.2126, 0.7152 and 0.0722.
Compare two luminances
Contrast ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05). Use full precision for the decision and round only the display. Reversing the colors does not change the ratio.
Inspect real context
The mathematical ratio helps assess solid color pairs. Photos, gradients, transparency, shadows and layers behind text require checking the effective background wherever the text appears.