Text contrast: the WCAG thresholds and the colors that fail them
Body text needs 4.5:1 against its background, large text 3:1, and field borders and icons 3:1 as well. Gray #999 on white gives 2.85:1, Tailwind’s gray-400 2.54:1: both fail. Below are the thresholds and computed pairs for the most common colors.
Thresholds
What
AA — the minimum
AAA — stricter
Criterion
Body text
4.5:1
7:1
1.4.3, 1.4.6
Large text: 24 px and up, or 18.66 px bold
3:1
4.5:1
1.4.3, 1.4.6
Icons, field borders, focus, chart lines
3:1
—
1.4.11
A disabled button, a logo, decorative text
not covered
—
1.4.3
Contrast is the ratio of the lighter color’s luminance to the darker one’s, from 1:1 (identical) to 21:1 (black on
white). Hue doesn’t enter the formula: red #ff0000 on green #00ff00 is 2.91:1, even though “the colors are different”.
Gray on white
Text color
Contrast
Passes
#000000
21:1
everything
#595959
7.0:1
AAA for text
#6b7280 — Tailwind gray-500
4.83:1
AA
#767676
4.54:1
AA — the lightest gray that passes
#777777
4.48:1
no — one step lighter, and it already fails
#999999
2.85:1
icons and borders only
#9ca3af — Tailwind gray-400
2.54:1
icons and borders only
#aaaaaa
2.32:1
no
#cccccc
1.61:1
no
Buttons: white text on color
Button background
White text
Passes
#2563eb — blue-600
5.17:1
AA
#dc2626 — red-600
4.83:1
AA
#3b82f6 — blue-500
3.68:1
large text only
#ef4444 — red-500
3.76:1
large text only
#16a34a — green-600
3.30:1
large text only
#22c55e — green-500
2.28:1
no
#f59e0b — amber-500
2.15:1
no; black text on it is 9.78:1
In Tailwind 4 the palette is defined in OKLCH, and the numbers differ slightly: gray-400 (#99a1af) is 2.60:1,
gray-500 (#6a7282) 4.84:1, blue-500 (#2b7fff) 3.76:1, green-500 (#00c950) 2.22:1. The conclusions are the
same: gray-500 passes AA, gray-400 is for icons and borders only, blue-500 for large text, green-500 for no text
at all.
Dark mode
Pair
Contrast
#ffffff on #000000
21:1
passes, but to people with astigmatism white letters on black look blurry, with a halo. There’s no dedicated study behind this — it’s a common reader complaint; general experiments show light text on dark is read more slowly
#f2eee8 on #131210 — this site’s text
16.2:1
AAA with room to spare, without pure white or pure black
#a39b90 on #131210 — this site’s captions
6.8:1
AA
#9ca3af on #111827
6.99:1
AA — the same gray-400 that fails on white
#6b7280 on #111827
3.67:1
no — the same gray-500 that passes on white
What to check with
Where
How
Chrome and Edge DevTools
select an element, click the color swatch in Styles — the picker has a Contrast ratio line with AA and AAA marks
DevTools, the Lighthouse tab
the Accessibility report lists elements with contrast below the threshold
Firefox
the Accessibility Inspector, the Contrast check
In code
the WCAG formula is 10 lines: each channel’s relative luminance, then (L1 + 0.05) / (L2 + 0.05)
If it doesn’t work
Captions and dates can’t be seen on a phone outdoors
Cause
Light gray on white: #aaa is 2.32:1. In bright sun a screen loses contrast, and pale text is the first to vanish.
Fix
Secondary text no lighter than 4.5:1: on white that’s #767676 or darker.
White text on a green button is hard to read
Cause
Saturated greens and yellows are light: white on #22c55e is 2.28:1, on #f59e0b 2.15:1.
Fix
A darker background (#16a34a — 3.3:1, too little for button text; #15803d — 5.02:1), or dark text: black on #f59e0b is 9.78:1.
In dark mode a gray that passed in the light theme can’t be read
Cause
The same gray on a dark background gives a different contrast: #6b7280 is 4.83:1 on white and 3.67:1 on #111827.
Fix
Pick and compute dark-mode colors separately instead of taking them from the light theme.