From screen values to relative luminance
The WCAG 2.2 contrast ratio for sRGB colours ranges from 1:1 to 21:1. The formula compares two relative luminances. Colour values such as an RGB channel of 128 must be converted before they can represent light.
Divide each 8-bit red, green and blue channel by 255. Apply the WCAG sRGB conversion separately to each result.
c_lin = c / 12.92 when c <= 0.04045
c_lin = ((c + 0.055) / 1.055)^2.4 otherwiseThe published cutoff is 0.04045. Some older references show 0.03928. Then apply the luminance weights and compare the lighter and darker luminances.
L = 0.2126 × R_lin + 0.7152 × G_lin + 0.0722 × B_lin
ratio = (L_lighter + 0.05) / (L_darker + 0.05)Black against white gives 1.05 divided by 0.05, or 21:1. Identical colours give 1:1, including black against black. The 0.05 term is fixed. The checker never measures the light falling on your screen.
Compare the ratio with the right threshold
For Contrast (Minimum), level AA, ordinary text needs 4.5:1 and large text needs 3:1, subject to the criterion’s exceptions. Large text is at least 18 points or 14 points bold. That is 24 CSS pixels or about 18.67 CSS pixels bold.
Contrast (Enhanced), level AAA uses 7:1 for ordinary text and 4.5:1 for large text. Non-text Contrast, level AA uses 3:1 against adjacent colours for visual information needed to identify controls and states, and for parts of graphics needed to understand them. Check the cue that carries information. A border that only decorates an already identifiable control is a different case.
Work through one pair
For #808080, each channel is 128 divided by 255, about 0.502. The power formula gives about 0.216. The channel weights sum to 1, so the grey’s relative luminance is also about 0.216. On white, the contrast is about 3.95:1. That passes the AA large-text threshold. Use a darker grey for ordinary text.
With opaque neutral greys on white, #767676 gives 4.542:1 and #777777 gives 4.478:1. The first passes 4.5:1. For the 3:1 threshold, #949494 gives about 3.033:1 and #959595 gives about 2.995:1. A checker that displays two decimal places might round the second to 3.00. Make the pass decision from the unrounded value.
Check the actual background
Opacity changes the colour you see. For a simple sRGB example, black text at 55% opacity over white gives about 4.76:1 before rounding the resulting channels to 8-bit values. Place the same text on #dddddd and it gives about 4.39:1. This crosses the ordinary-text threshold. Check the composited colours in each state. For text over an image or gradient, check the least favourable part the text crosses, or give the text a solid backing.
Try two adjacent grey swatches with a checker. Save the foreground and background values, the unrounded ratio and the criterion you checked. Then increase the difference enough that the result stays clear on a small phone in bright light.
Check your understanding
Black text at 55% opacity measures about 4.76:1 on white and 4.39:1 on a grey card. Why can the same text pass the AA ordinary-text threshold in one place and fail in the other?
Pick the one you would defend. Your answer stays private.
Your place and first choices stay on this browser. Classroom credit is recorded separately.
Stuck on something?Ask Meher, your AI tutor