ColorContrast
Engineering Analysis

Relative Luminance: The Number That Decides Every Contrast Ratio

Contrast ratios look arbitrary until you meet their numerator: relative luminance β€” a single number (0 to 1) describing how bright a color is to human vision. Understand how it is computed and every WCAG verdict becomes predictable.

The computation

  1. Linearize each channel: sRGB values are gamma-encoded for screens β€” divide by 255, then undo the gamma (values ≀ 0.03928 Γ· 12.92; others ^2.4 curve).
  2. Weight perceptually: 0.2126 R + 0.7152 G + 0.0722 B β€” green dominates because human vision's green receptors carry most brightness information.
  3. Ratio: (lighter L + 0.05) Γ· (darker L + 0.05).

The green lesson

The 0.7152 green weight explains the classic failure: pure red (#FF0000, luminance 0.21) against pure green (#00FF00, luminance 0.72) scores only 2.1:1 β€” a FAIL β€” despite being vividly different hues. Hue difference is not luminance difference; color-blind users (8% of men) see neither, and the ratio knew all along.

PairRatioVerdict
Black on white21:1AAA β€” the ceiling
#4B5563 on #F9FAFB (gray on gray)~8:1AAA β€” dull but readable
Pure red on pure green2.1:1FAIL β€” vivid β‰  readable
White on #4F46E5 (indigo button)~6.3:1AA+ β€” the good pattern

Why the 0.05 offsets

The +0.05 in the ratio prevents division by zero at pure black, and models the eye's contrast response at the extremes. The constants are calibration β€” the structure (luminance ratio) is the idea.

Building palettes that pass

  1. Design against luminance, then check hue: pick text and background luminances at least 0.25 apart for body text.
  2. Test every pair that touches: text/background, button/border, focus ring/background β€” contrast failures hide in states.
  3. Use the checker in design review, not after launch β€” the fix is always cheaper as a hex edit than as an audit finding.

Relative luminance is the bridge between what screens emit and what humans see β€” and the WCAG ratio is that bridge, audited. The math takes a screen to learn and pays out on every color decision after.