Basics

What is contrast ratio — and why green text only works on black

Illustration: a scale weighing colours by brightness

Take pure green, #00FF00. To the eye it's blindingly bright.

Now compute its contrast against a white background: 1.37:1. That's a failure, and a spectacular one — the threshold is 4.5:1. Text like that is nearly invisible on white.

The very same green on black gives 15.3:1 — almost as good as black on white.

Blue, #0000FF, behaves the exact opposite way: 8.59:1 on white (great), 2.44:1 on black (fail). Two "bright" colours, mirror images of each other. That's not a coincidence — it falls straight out of the formula.

What the number actually is

Contrast ratio is the ratio between the brightness of two colours: the text and the background under it. It's computed like this:

(L1 + 0.05) / (L2 + 0.05)

where L1 is the relative luminance of the lighter colour and L2 of the darker one. The range runs from 1:1 (identical colours, invisible text) to 21:1 (black on white — the maximum).

The WCAG standard requires:

  • 4.5:1 for regular text;
  • 3:1 for large text: 18pt and up, or 14pt bold and up (roughly 24px and 18.5px);
  • 3:1 for non-text things: input borders, icons, the focus indicator, parts of charts;
  • logos and incidental text inside a photo are exempt — you don't have to count them.

No rounding allowed: 4.499:1 does not meet the threshold. The standard spells that out.

Why colour doesn't save you: the formula only measures brightness

Here's the key to the whole story. Luminance is computed like this:

L = 0.2126 × R + 0.7152 × G + 0.0722 × B

Look at the coefficients. Green contributes 71% of the brightness. Red, 21%. Blue, a mere 7%.

That's not arbitrary, it's physiology: the human eye perceives the green part of the spectrum as the brightest. The standard does this deliberately — a luminance requirement works regardless of how a person perceives colour. It helps someone with colour blindness exactly as much as anyone else.

Which explains all the "weird" behaviour that breaks designers' brains:

  • Green is nearly white to the formula. So green text only lives on dark backgrounds.
  • Blue is nearly black to the formula. So blue text only lives on light ones. Navy on black is unreadable, even though "the colours are clearly different."
  • Yellow is the sneakiest. Pure #FFFF00 on white gives 1.07:1. Practically invisible, despite feeling bright.
  • An orange button #E67E22 with white text: 2.85:1. A failure that looks perfectly cheerful.

The difference in hue is obvious to your eye and invisible to the formula. It only looks at lightness.

Why 4.5 and not a round 5

The number was derived, not decreed. The minimum for normal vision under an older industrial standard is 3:1. On top of that, the standard budgets for age-related loss of contrast sensitivity: 4.5:1 roughly corresponds to 20/40 visual acuity — typical for someone around eighty. The AAA level at 7:1 covers 20/80.

So 4.5:1 isn't "for blind people." It's "so your grandfather can read it" — and so can you, on a phone in the sun.

A practical gift from that maths: #767676 is the lightest grey that still passes 4.5:1 on white (4.54:1). The designer-favourite #999 gives 2.85:1 and fails. If you remember one number from this article, make it 767676.

Not just text: buttons, fields and focus

This is the most forgotten part. The 3:1 threshold also applies to non-text elements: if an input is only recognisable by a pale grey border, that border needs 3:1 against the surrounding background. Same for the focus ring that shows where you are when tabbing through the page — people love to kill it with outline: none, and then a person is lost on your page.

A trap of its own is dark mode. People often just invert the palette and call it done. But contrast has to be recomputed: pairs that worked beautifully on white fall apart on graphite — largely because of blue.

How do I check contrast in ten seconds?

In the browser: right-click the text, "Inspect," then click the colour swatch in the styles panel. Developer tools show you the ratio and a pass/fail mark, and offer the nearest passing shade.

Does contrast count against a background image?

Formally, against whatever colour is actually under the text. If the background is a photo, there are no guarantees: the ratio differs across the image. That's why people put a translucent scrim or a shadow behind the text instead of hoping for the best.

Is passing 4.5:1 enough to call a site accessible?

No, it's one requirement among many. Contrast says nothing about the keyboard, alt text or heading structure — and it's easy to pass on a site that's unusable with a screen reader.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →