Why Pure Blue Passes WCAG AA and Pure Green Fails
Contrast ratio is not about how different two colours look. A line-by-line walkthrough of the sRGB luminance formula, why the green channel carries 71.5% of the answer, where two-decimal rounding lies, and what a checker cannot tell you.
What this guide covers
- 1. The formula, line by line
- 2. Why the green channel decides almost everything
- 3. Two decimals can disagree with the verdict
- 4. Three-digit hex is not portable
- 5. HSL is a lossy projection, not another representation
- 6. What a contrast checker cannot tell you
- 7. A workflow that uses these numbers properly
- 8. Frequently asked questions
- 9. The one-line version
Put pure blue text (`#0000ff`) on white and it scores 8.59:1. Put pure green (`#00ff00`) on the same white and it scores 1.37:1. Both are fully saturated primaries at maximum channel value; one clears the 7:1 AAA threshold for normal body text, and the other fails even the 3:1 minimum for large text and UI components.
Nothing here is a bug in the checker. It follows directly from three coefficients in the Contrast Checker on this site, and the same arithmetic sits behind almost every accessibility audit you will ever run. If you have ever picked a colour that looked crisp but failed an audit, this is the reason.
The formula, line by line
The checker takes two hex colours and turns each into three 0–255 channel values. Then it does something that trips people up: it does not average those channels. It first removes the sRGB gamma curve. Every channel is divided by 255 and passed through a piecewise function:
Linearising matters because screen values are not proportional to emitted light. A channel at 128 is not half as bright as one at 255; after the curve it is roughly 0.216 rather than 0.5. Averaging the raw bytes would give a completely different answer. The three linearised channels are then weighted and summed as `0.2126 * R + 0.7152 * G + 0.0722 * B` to produce relative luminance `L`.
Finally the ratio is `(L_lighter + 0.05) / (L_darker + 0.05)`. The 0.05 offset keeps the denominator away from zero for pure black and caps the scale: white against black gives `(1 + 0.05) / (0 + 0.05) = 21`, so 21:1 is the mathematical ceiling, not a particularly good design choice. The formula takes a max and a min rather than a foreground and a background, which means it is symmetric — swapping the two colours cannot change the score.
Why the green channel decides almost everything
Those weights come from human photopic vision: the eye is most sensitive to middle wavelengths and least to short ones. Green alone contributes 0.7152 of luminance, red 0.2126, and blue 0.0722 — about ten times less than green. That single fact explains the opening puzzle. Pure green is very bright to the formula, so it sits close to white and the ratio collapses; pure blue is nearly dark, so it sits close to black and the ratio is high.
- `#000000` on `#ffffff` → 21.00:1 — the ceiling, AA and AAA for everything.
- `#0000ff` on `#ffffff` → 8.59:1 — blue passes AA and AAA for normal text despite looking vivid.
- `#ff0000` on `#ffffff` → 4.00:1 — red passes large text at 3:1 but misses normal text at 4.5:1.
- `#00ff00` on `#ffffff` → 1.37:1 — green fails every threshold in the table.
- `#777777` on `#ffffff` → 4.48:1 — misses AA by 0.02, the classic almost-passing grey.
- `#767676` on `#ffffff` → 4.54:1 — one hex step darker and it passes.
- `#2563eb` on `#ffffff` → 5.17:1 — a common UI blue that clears AA with modest headroom.
The practical consequence: saturation and contrast move in opposite directions. Adding green to a colour raises its luminance and reduces its ratio against white; adding blue lowers luminance and raises it. Designing by eye optimises for the wrong variable. This is also why a checker reports five separate verdicts rather than one — 4.5:1 for normal AA, 7:1 for normal AAA, 3:1 for large AA, 4.5:1 for large AAA and 3:1 for UI components and graphics. The ratio does not know the font size; the *threshold* does.
Two decimals can disagree with the verdict
The checker renders its score with `r.toFixed(2)` but evaluates pass/fail against the unrounded `r`. A true ratio of 4.495 displays as 4.50:1 while `r >= 4.5` is false, so the row says Fail underneath a number that appears to meet the requirement. Near the boundary this is easy to hit: `#777777` is genuinely 4.4781:1, shown as 4.48.
Three-digit hex is not portable
CSS allows shorthand hex, and the two tools on this site handle it differently. The Contrast Checker expands a three-digit value by duplicating each nibble, so `#f0a` becomes `#ff00aa` and scores 3.60:1. The Color Converter uses a regex that requires exactly three two-digit groups, so the same input produces *Invalid color format. Use #RRGGBB.* Both behaviours are defensible — one follows CSS shorthand, the other validates a strict interchange format — but they are not interchangeable. Expand to six digits before you pass a value between tools, or between a design token and a test.
HSL is a lossy projection, not another representation
The Color Converter also emits HSL, and its `rgbToHsl` rounds all three outputs: hue to whole degrees, saturation and lightness to whole percentages. `#2563eb` comes out as `hsl(221, 83%, 53%)`. With only 101 possible saturation and lightness values, converting back cannot in general reconstruct the original RGB — the rounding discards information on the way out.
- `#808080` → `hsl(0, 0%, 50%)`. When all channels are equal, hue is mathematically undefined and the code assigns 0 (red). Saturation is 0, so the arbitrary hue is invisible — until you use it as a base for generating variants.
- `#ff00ff` → `hsl(300, 100%, 50%)`, which happens to round-trip cleanly. Clean examples are the exception, not the rule.
- Any workflow that reads HSL, adjusts lightness, and writes RGB back is doing a lossy round trip. For accessible palettes, keep the original hex as the source of truth and re-run the contrast calculation on every derived value.
What a contrast checker cannot tell you
- Semi-transparent colours. The formula consumes opaque RGB only. An `rgba()` foreground or an 8-digit hex with alpha must be composited over its actual background first; entering the raw channel values gives a meaningless ratio.
- Colour-vision deficiency and legibility. Luminance contrast says nothing about whether two hues are distinguishable, whether a thin font weight survives anti-aliasing, or whether a busy background texture destroys readability at the same nominal ratio.
- Non-text contrast. Icons, input borders, focus rings and chart series use the 3:1 threshold, which is why the tool lists it separately. A palette can pass all text checks and still have invisible controls.
- Future perceptual models. The WCAG 2.x sRGB formula is known to be imperfect, particularly for some dark-mode pairs, and newer proposals use different perception-based maths. Compliance today is still judged against this formula, so an audit result and a perceptual opinion can legitimately disagree.
- Layout and context. The score assumes a solid background and a single foreground. Gradients, images behind text, and overlapping translucent layers need to be sampled at their worst point, not their average.
A workflow that uses these numbers properly
- Normalise first. Expand shorthand to six digits in the Color Converter and keep the hex, not the rounded HSL, as the canonical token.
- Test real pairs. Run the actual foreground/background combination through the Contrast Checker. Because the formula is symmetric, order does not matter — but which shade is on which surface does.
- Leave headroom. Anything between 4.5 and about 4.8 is one rounding decision away from failing. Treat 5:1 as the working target, not 4.5:1.
- Re-test variants. Colours from the Color Palette or Gradient Generator need their own measurement; a shadow from the Text Shadow Generator does not contribute to text contrast.
- Run dark mode separately. Inverting the palette does not preserve ratios, because the luminance curve is not symmetric around the midpoint.
Frequently asked questions
Why does pure green fail so badly? Because green carries 0.7152 of the luminance weight. `#00ff00` has relative luminance 0.7152, close to white's 1.0, so `(1.05) / (0.7652)` is only about 1.37. Blue carries 0.0722 and behaves almost like a dark colour.
Is 21:1 the maximum possible? Yes, for opaque sRGB colours. The 0.05 offset in both numerator and denominator fixes the ceiling at `(1 + 0.05) / (0 + 0.05) = 21`. Pure black on pure white is the only way to reach it.
Does swapping text and background change the result? No. The implementation takes `Math.max(L1, L2)` and `Math.min(L1, L2)`, so the ratio is symmetric. The WCAG thresholds are also applied to the ratio, not to either colour individually.
Why does the display say 4.50:1 while the row says Fail? Display uses `toFixed(2)`; the verdict uses the unrounded value. A ratio from 4.495 to just under 4.5 rounds up on screen but still fails `r >= 4.5`.
Can I generate an accessible palette by shifting HSL lightness? Only as a starting point. HSL output here is rounded to integers, and perceptual lightness is not the same as WCAG luminance. Generate candidates in HSL if you like, then measure the final hex values.
Does passing 4.5:1 mean my page is WCAG compliant? It satisfies one success criterion for that text pair. Font size, weight, focus indicators, non-text contrast and semantic structure are separate requirements, and this tool measures none of them.
The one-line version
Contrast ratio is a measurement of linearised luminance weighted heavily toward green, not a measurement of how different two colours look. Trust the number, but know which decisions — gamma, weights, the 0.05 offset, and two-decimal display — put it there.
Tools run privately in your browser
Every tool referenced in this guide processes your input in the browser rather than uploading it to a server we operate, and requires no account. A typical single job stays free. Larger batches, history export, and an ad-free page are optional on Pro. A few tools load a processing engine from a CDN on first use; see the privacy policy for details. Browse the full toolbox →