Key takeaways
- Aim for at least 4.5:1 for normal text and 3:1 for large text and UI components (WCAG AA).
- Test every state: default, hover, focus, disabled-looking and dark mode.
- Never rely on color alone to convey meaning.
Why color contrast matters
Contrast is the difference in brightness between text and its background. Low contrast makes content hard to read for people with low vision or color deficiency, and for anyone using a phone in bright sunlight.
Good contrast improves readability for everyone and is one of the most common requirements in accessibility standards and laws.
Understanding WCAG contrast ratios
The Web Content Accessibility Guidelines (WCAG) express contrast as a ratio from 1:1 (no difference) to 21:1 (black on white). Level AA requires 4.5:1 for normal text and 3:1 for large text, user interface components and meaningful graphics.
Level AAA is stricter: 7:1 for normal text and 4.5:1 for large text. Large text means roughly 24px regular or 18.7px bold and above.
How the ratio is calculated
Each color is converted to relative luminance, a measure of perceived brightness after correcting for how screens display sRGB. The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05).
You do not need to do the math by hand: enter two HEX colors in a contrast checker and it reports the ratio and whether it passes AA and AAA.
How to test your colors
Enter your text color and background color, read the ratio, and check the pass or fail result for each level. Then test the other pairs in your design: buttons, links, form borders, placeholder text and text over gradients.
Repeat for dark mode and for hover, active and focus states, because each can use different colors.
Fixing a failing color pair
Darken the text or lighten the background until the ratio passes, keeping the same hue so your brand stays recognizable. Small changes in lightness are often enough.
If a brand color cannot pass as text, use it for large headings or decorative areas and choose a darker shade for body text and links.
Common mistakes to avoid
Light gray placeholder text, text over photos without an overlay, and thin low-contrast icons are frequent failures. Another common error is using color alone to show errors or links; add text, icons or underlines as well.
Remember that automated checks cannot judge everything, so review designs with real users or a colorblindness simulation too.
Frequently asked questions
What contrast ratio do I need?+
For WCAG AA, use at least 4.5:1 for normal text and 3:1 for large text and interface components. AAA asks for 7:1 for normal text.
Does dark mode need to meet contrast rules?+
Yes. Every theme must meet the same contrast requirements for text and interface elements.
Try these free tools
- colorColor Contrast CheckerColor Contrast Checker: find problems fast and see clear results. Free and runs in your browser.Open tool
- colorWCAG Contrast TesterWCAG Contrast Tester: find problems fast and see clear results. Free and runs in your browser.Open tool
- colorColor Blindness SimulatorColor Blindness Simulator: experiment with live controls and see the result instantly. Free and private.Open tool