How this calculator works
- Step 1Undo screen gammaLinear lightEach red, green and blue value becomes the light it really gives off.
- Step 2Weigh the channels21% · 72% · 7%Eyes are most sensitive to green, least to blue.
- Step 3Compare the two(L1 + 0.05) ÷ (L2 + 0.05)From 1:1 (identical) to 21:1 (black on white).
Contrast is about lightness, not hue. Two very different colours can be equally light and hard to tell apart for people with low vision or colour blindness.
Worked example: a grey that just misses
#777777 on white is 4.47:1, just under the 4.5:1 needed for normal text. #767676 reaches 4.54:1.
- Relative luminance
L = 0.2126 R + 0.7152 G + 0.0722 B (linear values)- Contrast ratio
(L lighter + 0.05) ÷ (L darker + 0.05)
- Luminance of white1.0000
- Luminance of #7777770.1845
- Ratio4.4781
- Shown as (cut, not rounded)4.47:1
- Nearest passing grey#767676, 4.54:1
The ratio is cut to two decimals rather than rounded, so 4.478 shows as 4.47:1 and never looks like it passes 4.5:1.
Reading the result
- AA (the usual target)4.5:1 · 3:1 largeRequired by most accessibility policies and laws.
- AAA (enhanced)7:1 · 4.5:1 largeStronger contrast for reading-heavy pages.
Pure red on white is 3.99:1: fine for large headings, too faint for body text.
- Large textAt least 24 px, or 18.66 px when bold.
- Icons and bordersNeed 3:1 against what is next to them.
- Logos and disabled controlsExempt from the contrast rules.
- Translucent coloursBlended over the background before measuring.
Related colour tools
Contrast is checked on the final colours. Converting between formats comes first.
To convert a colour between HEX, RGB, HSL and OKLCH, use the color converter. For hex arithmetic on colour values, try the hex calculator.
Common mistakes
Mistake: Checking only the light theme.
Instead: Check every colour pair in dark mode too.
Mistake: Rounding 4.48:1 up to 4.5:1.
Instead: Treat anything below 4.5:1 as a fail for normal text.
Mistake: Using colour alone to show meaning.
Instead: Add text, an icon or a pattern as well.
Read how we test our calculators, or browse more developer tools.