Colour contrast and WCAG
"Is this readable?" is the wrong question to ask a designer, because the answer is always yes. The useful question is "what contrast ratio does this pair reach, and does it clear the WCAG threshold for its size?" The Web Content Accessibility Guidelines turn that into a number you can check before you ship, and the check is quick enough to run on every colour pair you pick.
What the contrast ratio means
The WCAG contrast ratio is a single number comparing the relative luminance of a foreground colour and a background colour, from 1:1 (same colour, invisible) to 21:1 (black on white). It is deliberately colour-blind: it only cares about brightness, so two colours that look "fine" to you can still fail, and a pair that passes can still be illegible if the colours are similar in hue — which is why the number is necessary and not sufficient.
The ratios you must hit
| Content | AA (minimum) | AAA (enhanced) |
|---|---|---|
| Normal text, under 18 pt (or under 14 pt bold) | 4.5 : 1 | 7 : 1 |
| Large text, 18 pt and up (or 14 pt bold and up) | 3 : 1 | 4.5 : 1 |
| Interface components, icons, graphics, focus outlines | 3 : 1 | Not defined |
Large text is roughly 24 px at typical screen resolution, or 18.66 px bold — the guideline's "18 pt / 14 pt bold" is anchored to a print point, so in practice most teams test at 24 px and 19 px bold. The component row (SC 1.4.11) covers the parts of a control you must be able to perceive: the icon, the border of a text field, a focus ring, a chart's data marks.
How the number is calculated
Each channel of an sRGB colour is linearised (a value under 0.03928 divides by 12.92,
otherwise it is raised to 2.4), then combined as 0.2126·R + 0.7152·G + 0.0722·B to give the relative luminance. The ratio is (Lighter + 0.05) / (Darker + 0.05), and the 0.05 is why pure black and pure white
reach 21:1 instead of an infinite number. In practice it means the arithmetic is different
from "how much darker" the two colours look — the ratio is what matters, not the difference.
That is also why small lightness changes matter more than you expect: #767676 on white
reaches about 4.5:1 and passes AA for normal text, while #777777 — one step darker
— sits just under 4.5:1 and fails. A "readable-looking" grey is frequently a failing grey.
How to check a pair
The Colour Contrast Checker takes a foreground and a background colour and returns the WCAG ratio with AA and AAA verdicts for normal text, large text and graphics, plus an approximate APCA value as a second opinion. Nothing leaves the page, so you can iterate on a palette without pasting brand colours into a stranger's server.
- Check every state, not just the default: hover, focus, pressed, disabled, visited links.
- Check placeholder text inside inputs, which is often the lightest text on the page.
- Check the surface behind the text — a white card on a tinted page is a different pair from white on white.
- For text over an image or gradient, find the lightest and darkest part the text crosses and check both; a single ratio does not exist for a gradient.
- Check both themes if you ship dark mode. A colour that passes on a white background can fail on a near-black one, because the ratio shrinks from the other side.
The failures that ship most often
- Grey placeholder and helper text sitting just below 4.5:1.
- White or near-white text on a light tint, or brand colours used as body copy.
- Red and green used as the only difference between success and failure states.
- Links inside body text identified by colour alone, with no underline (SC 1.4.1).
- Disabled-looking buttons that are genuinely disabled, exempt from the rule and still unreadable.
- Thin fonts at small sizes, where a passing ratio still reads poorly.
A practical workflow
Pick the pairs you intend to use, check each one, and when a pair fails, change the lightness rather than the hue: darkening a mid-grey by ten percent usually recovers the ratio without changing the feel of the design. Run the check again as the last step before a release, because a later colour tweak can quietly undo it, and put the ratio in your design notes next to the colour so the next person does not have to rediscover it.
Beyond contrast
WCAG contrast is the floor, not the ceiling. Converting colours between hex, RGB and HSL helps when you need to adjust luminance directly, and building a palette makes it easier to keep a tint of a brand colour passing. Checks are cheap; put them in the routine rather than in a pre-launch panic.
More guides
- Base64 explained — what Base64 is and where it belongs.
- Which hash should I use? — digests, passwords and HMAC.
- Cron syntax cheat sheet — scheduling recurring jobs.