Low contrast text is the most common accessibility failure on the web. Here is how to avoid it.
1. Trusting your own eyes
Your monitor, brightness and eyesight are not your users'. Measure the ratio instead of guessing.
2. Wrong thresholds
WCAG AA needs 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold). AAA needs 7:1 and 4.5:1.
3. Forgetting UI components
Borders of inputs, icons and focus rings also need 3:1 against their background.
4. Light gray placeholder text
Placeholders are text too. The default light gray on white often fails.
5. Contrast on images and gradients
Text over a photo has no single background. Add an overlay or measure the worst spot.
.btn { background: #1a56db; color: #fff; } /* 6.6:1, passes AA */
Check it
I use the color contrast checker and the color palette generator to test pairs fast. They are free and client-side, from webdevtoolbox.com.
Top comments (0)