What the contrast ratio means
Contrast ratio compares the brightness of two colors on a scale from 1:1 (identical colors, unreadable) to 21:1 (black on white). The higher the ratio, the easier text is to read, especially for people with low vision or color blindness, and for anyone reading a phone in bright sunlight.
The Web Content Accessibility Guidelines (WCAG) set the minimums most websites aim for. Many countries use WCAG level AA as the legal accessibility standard.
WCAG contrast requirements
| What | AA (minimum) | AAA (enhanced) |
|---|---|---|
| Normal text | 4.5:1 | 7:1 |
| Large text (24px+, or 18.66px+ bold) | 3:1 | 4.5:1 |
| Icons, buttons, form borders and chart lines | 3:1 | Not defined |
Logos and purely decorative text don't have a contrast requirement.
How to fix low contrast
- Use the suggestion. When a pair fails, the checker suggests the nearest text color that passes, keeping the same hue.
- Change lightness, not hue. Contrast depends on brightness. Swapping blue for green barely helps; making the text darker or lighter does.
- Watch out for gray text. Light gray on white is the most common failure on the web. #767676 is the lightest gray that passes AA on white.
- Make it bigger. If you can't change the colors, larger or bold text only needs 3:1.
How contrast ratio is calculated
Each color's relative luminance (L) is calculated from its red, green and blue values, weighted by how sensitive our eyes are to each: green counts most, blue least. The ratio is then (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color. Ratios are rounded down, so a pair at 4.49:1 doesn't pass a 4.5:1 requirement.
Frequently asked questions
What is a good contrast ratio?
At least 4.5:1 for normal text and 3:1 for large text meets WCAG AA, the standard most sites follow. 7:1 or more is excellent and meets AAA.
What is the contrast ratio of black on white?
21:1, the highest possible.
Does gray text on white pass WCAG?
Only if it's dark enough. #767676 is the lightest gray that meets 4.5:1 on a white background; anything lighter fails for normal text.
What counts as large text?
Text at least 24px (18pt) in regular weight, or at least 18.66px (14pt) in bold.
Do I need to check button and icon colors?
Yes. Under WCAG 2.1, icons, form field borders and other important graphics need at least 3:1 contrast against what's next to them.