Color relative luminance and contrast ratio
Compare foreground and background colors to calculate relative luminance and contrast ratio
Calculates the contrast ratio between solid sRGB colors. It does not determine accessibility conformance for an entire site.
Results
—
- Foreground relative luminance after compositing
- —
- Background relative luminance after compositing
- —
Results update automatically when the required values are entered.
Method, applicability and sources
Calculation method
Normalize each HEX channel to 0–1 and composite using Source Over with foreground/background opacity a (0–1). For a partially transparent background, displayed background B′=aB×B+(1−aB)×underlay color. Displayed foreground F′=aF×F+(1−aF)×B′. Linearize each displayed sRGB channel c as c/12.92 when c≤0.04045, otherwise ((c+0.055)/1.055)^2.4. Relative luminance L=0.2126R+0.7152G+0.0722B. Contrast ratio=(higher L+0.05)/(lower L+0.05). Internal calculations are not rounded. Display up to 3 decimal places for contrast and 6 for luminance.
Worked example (hypothetical values)
An opaque #000000 foreground on an opaque #FFFFFF background has relative luminances of 0 and 1 and a ratio of 21:1. For #777777 on #FFFFFF, the ratio is approximately 4.478:1.
Applicability and limitations
Numerical design comparison of solid foreground and background colors representable in sRGB and displayed in layers. Does not evaluate images, gradients, blend modes, wide-gamut colors, APCA, text size or layout. It does not determine WCAG AA/AAA conformance or audit an entire page.
Methods used
- sRGB + Source Over (WCAG 2.2 (2024-12-12) / Compositing Level 1 (2024-03-21)): scope Solid sRGB foreground and background colors over an opaque solid underlay; region global
Method and sources
Method: WCAG 2.2 Recommendation (2024-12-12) / Compositing and Blending Level 1 CR Draft (2024-03-21). Data recorded: 2026-11-13.