Color Contrast and WCAG: A Practical Guide
Updated · 2 min read
Low-contrast text is one of the most common accessibility problems on the web, and one of the easiest to fix. This guide explains the contrast ratio in plain language, which numbers you need to hit, and how to adjust colors that fail.
What is a contrast ratio?
The contrast ratio compares how bright two colors are, from 1:1 (identical, e.g. white on white) to 21:1 (black on white). The higher the ratio, the easier the text is to read, especially for people with low vision, on cheap screens, or in bright sunlight.
The WCAG thresholds
| What | Level AA (minimum) | Level AAA (enhanced) |
|---|---|---|
| Normal text | 4.5:1 | 7:1 |
| Large text (24px+, or 18.66px+ bold) | 3:1 | 4.5:1 |
| Icons, input borders, focus rings | 3:1 | - |
Most laws and accessibility policies point to WCAG 2.1 or 2.2 level AA, so 4.5:1 for body text is the number to remember. Disabled controls, logos and purely decorative elements are exempt.
Examples
#767676on white is about 4.5:1, roughly the lightest gray that still passes for body text.#999999on white is about 2.8:1, which fails even for large text.- White on Tailwind blue-600 (
#2563EB) is about 5.2:1 and passes, while white on blue-400 fails.
How it's calculated
Each color is converted to its relative luminance, a measure of perceived brightness where green counts the most and blue the least (the weights are 0.2126 R, 0.7152 G and 0.0722 B after gamma correction). Then:
ratio = (Llighter + 0.05) / (Ldarker + 0.05)
You don't need to do this by hand: the color converter and every color page on this site show the ratio against white and black with a pass/fail grade.
How to fix a color that fails
- Keep the hue, change the lightness. Darken the text color (or lighten the background) in small steps until it passes. Your brand still looks like your brand.
- Use the brand color for big things, a darker shade for text. A bright brand yellow can be a button background with black text, while links use a deep amber.
- Make the text larger or bolder. Large text only needs 3:1, which is useful for headings in a light brand color.
- Pick from a tested scale. In Tailwind's default palette, every shade from 700 to 950 passes 4.5:1 on white, while 600 passes only for cooler and darker colors (blue, indigo, violet, red, gray and similar) and fails for yellow, orange, green and cyan. Shades 50-300 pass on
slate-900. The Tailwind color pages list the contrast of every shade.
Common mistakes
- Placeholder text in forms is often far too light. If it carries information, it must meet 4.5:1.
- Text on images and gradients: check the worst spot, not the average. Add a dark overlay or a text shadow if needed.
- Relying on color alone: an error shown only by red text is invisible to many color-blind users. Add an icon or a message.
What about WCAG 3 and APCA?
A new contrast method called APCA is being developed for the future WCAG 3. It models perception more accurately, especially for dark mode. It is still a draft, so WCAG 2.x ratios remain the standard you should test against today.