Colour Contrast Ratio Calculator (WCAG)

Measures the contrast between a text colour and its background using the WCAG definition. The ratio runs from 1 for identical colours to 21 for black on white; body text needs at least 4.5, large text at least 3.

This tool measures the contrast between a text colour and its background, using the definition given in the Web Content Accessibility Guidelines.

C=Y1+0.05Y2+0.05C = \dfrac{Y_1 + 0.05}{Y_2 + 0.05}

Here Y1Y_1 is the relative luminance of the lighter colour, Y2Y_2 that of the darker and CC the contrast ratio. The 0.05 allows for the fact that a screen cannot produce a true black and always reflects a little ambient light; without it, black against black would give an infinite ratio.

Relative luminance

Y=0.2126Rl+0.7152Gl+0.0722BlY = 0.2126 R_l + 0.7152 G_l + 0.0722 B_l

Here RlR_l, GlG_l and BlB_l are the channels converted back to values proportional to the light emitted. Screen colours are encoded to suit the eye rather than the physics, and that encoding has to be undone before brightnesses can be compared.

The levels

The ratio runs from 1, for two identical colours, to 21, for black against white.

Large text means 18 point or above, or 14 point and bold.

Worked example

Grey text at (90, 90, 90) on a white background gives a contrast ratio of 6.90, which meets AA.

The text has a relative luminance of 0.102 and the background 1, so (1 + 0.05) ÷ (0.102 + 0.05) = 6.90. That falls just short of 7, so AAA is not met.

Points to watch

Contrast is not the whole of readability. Size, weight and the typeface itself all bear on it.

Never carry meaning by colour alone: it does not reach readers who cannot separate the colours in question.