Color Contrast and WCAG: A Practical Guide
· 4 min read
What contrast ratios mean, which WCAG levels apply to text, icons and buttons, the mistakes that fail audits most often and how to fix them.
Low contrast is one of the most common accessibility problems on the web, and one of the easiest to fix once you know what to measure. This guide explains what a contrast ratio is, which thresholds apply to which parts of an interface, and how to fix a failing color without losing the look of your design.
What a contrast ratio measures
A contrast ratio compares the relative luminance of two colors — roughly, how much light each one gives off as perceived by the eye. The formula from WCAG is:
ratio = (L1 + 0.05) / (L2 + 0.05)where L1 is the luminance of the lighter color and L2 of the darker one. The result runs from 1:1 (two identical colors) to 21:1 (black on white).
Hue does not enter the formula. Red and green of the same luminance have a ratio close to 1:1, even though they look completely different to most people. That is intentional: for readers with color vision deficiencies, lightness difference is what separates text from its background.
The thresholds that matter
| What | AA (minimum) | AAA (enhanced) | WCAG criterion |
|---|---|---|---|
| Normal text | 4.5:1 | 7:1 | 1.4.3 / 1.4.6 |
| Large text | 3:1 | 4.5:1 | 1.4.3 / 1.4.6 |
| UI components and graphics | 3:1 | — | 1.4.11 |
Large text means at least 18 points (about 24px) at regular weight, or 14 points (about 18.66px) in bold. Anything smaller counts as normal text, including most body copy, labels and buttons.
UI components and graphics covers the visual parts someone needs to see to use the interface: input borders, checkbox outlines, icons that carry meaning, chart lines, and focus indicators. Each needs 3:1 against the colors next to it.
AA is the level most laws and policies refer to. AAA is not required for whole sites, but 7:1 is a comfortable target for long-form body text, especially for older readers and on screens viewed in bright light.
Gray text: the classic near-miss
Light gray text on white is the most frequent failure, because it looks fine on a good monitor. The line between passing and failing is narrower than you might expect:
#767676 is the lightest neutral gray that passes AA on white. One step lighter, #777777, fails. Ratios are usually compared after rounding down, so 4.48:1 does not count as 4.5:1.
Mistakes that fail audits most often
White text on bright brand colors
Many brand colors are mid-tones — oranges, yellows, light greens, cyans. White on them is often below 3:1. A coral like #FF7A59 gives only 2.57:1 with white text, but 6.78:1 with near-black #1A1A1A. If dark text on your button does not fit the brand, darken the button color instead.
Placeholder text used as a label
Placeholders are usually styled light gray, so they often fail 4.5:1. They also disappear as soon as someone starts typing. Keep a visible label, and if the placeholder holds useful information, give it real text contrast.
Faint input borders
A text field outlined in #E0E0E0 on white has a ratio of 1.32:1. For someone with low vision the field is simply not there. Borders that identify a control need 3:1 under criterion 1.4.11. If you prefer a softer look, use a filled background for the field along with a darker bottom border.
Text on images and gradients
Contrast must hold across the whole area behind the text. On a photo or gradient, check the lightest region under light text (or the darkest region under dark text). A semi-transparent overlay or a solid band behind the text is the usual fix.
Forgotten states
Hover, focus, selected and error states need the same contrast as the default state. Focus rings in particular are often a pale tint of the brand color that disappears against the background.
What is exempt
- Disabled controls that cannot be used.
- Purely decorative elements and text inside images that carry no information.
- Logos and brand names.
Exempt does not mean ignored — a disabled button that cannot be seen at all is still confusing — but these are not counted as failures.
How to fix a failing pair without changing the design
Swapping a failing color for black or white works, but it erases the palette. A better approach is to change only the lightness of one color while keeping its hue and saturation. A blue that is too light for text becomes a deeper blue of the same family, and the design still feels the same.
This is easiest in a perceptual color space such as OKLCH, where the lightness channel matches what the eye sees much more closely than HSL. In HSL, a yellow and a blue at the same "50% lightness" have very different contrast; in OKLCH, equal lightness values look roughly equally light.
The Colorset contrast checker does exactly this: when a pair fails, it searches for the nearest passing color by adjusting only OKLCH lightness, for the text and for the background separately. Every palette page also lists the measured ratio of each role pairing in light and dark mode.
A note on WCAG 3 and APCA
A new contrast method called APCA is being explored for a future version of the guidelines. It accounts for font size, weight and whether text is light-on-dark or dark-on-light, which the current formula does not. It is still a draft, so WCAG 2 ratios remain the standard to meet today. If you meet 4.5:1 for body text and 3:1 for components, you will be in good shape either way.
Checklist
- Body text and labels: 4.5:1 or more (aim for 7:1 for long reading).
- Large headings: 3:1 or more.
- Input borders, icons, chart lines, focus rings: 3:1 against neighbors.
- Button labels checked against the button color, not the page.
- Hover, focus, error and dark mode states checked too.
- Text over images checked at its worst point.