Color Contrast and Readability on Screens
How contrast ratios work, the WCAG thresholds to meet, and the type and color choices that keep text readable.
Key takeaways
- Contrast depends on the difference in relative luminance between two colors, not on how different their hues look.
- WCAG level AA asks for 4.5:1 for normal text and 3:1 for large text and important interface graphics.
- Never rely on color alone to carry meaning, since many people can't distinguish some hues.
- Line length, size, spacing and weight affect readability as much as color does.
- Test every state and theme, including hover, disabled, error, dark mode and text over images.
Text is readable on a screen when it differs enough in lightness from its background and is set large and spaced well enough to follow. The Web Content Accessibility Guidelines (WCAG) turn the first part into a number: aim for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text at level AA. You can check any pair of colors in seconds, and fixing failures usually means darkening a gray or a brand color.
This article explains what the ratio measures, where the thresholds apply, what they miss and how to choose colors and type that work for more people.
What a contrast ratio measures
WCAG defines relative luminance as a weighted measure of how light a color appears, after converting its red, green and blue values from the screen's encoding into linear light. Green counts most and blue least: roughly 0.2126 for red, 0.7152 for green and 0.0722 for blue.
The ratio is then (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color's luminance and L2 the darker's. The scale runs from 1:1, identical colors, to 21:1, pure black on pure white.
This is why two vivid colors can fail badly. Bright red and bright green look different to many people but may be similar in luminance, and to some readers they look nearly the same.
Higher means more separation between foreground and background. Basis: WCAG 2.x contrast success criteria 1.4.3, 1.4.6 and 1.4.11.
Where the thresholds apply
Large text means at least 18 point, or 14 point if bold. In CSS terms that is about 24 pixels, or about 18.7 pixels bold. Thin display fonts may remain hard to read even when they pass.
Non-text contrast of 3:1 applies to the visual cues needed to identify controls and their states, such as an input border, a focus indicator or a checkbox tick, and to parts of graphics needed to understand them.
Exceptions include logos, purely decorative text and inactive controls. Being exempt doesn't make faint disabled text pleasant, so keep it legible where people need to know what it says.
A useful reference point: the gray #767676 on white sits just above 4.5:1, so anything lighter on white fails for body text.
Check your colors
A contrast checker takes two colors and reports the ratio. Browser developer tools often show it in the color picker too. Check these combinations in particular:
- Body text, secondary text and captions on each background.
- Links, both against the background and, if they aren't underlined, against surrounding text.
- Button labels in default, hover, focus and pressed states.
- Placeholder text and input borders.
- Error, warning and success messages.
- Text on photos and gradients, at the worst spot, not the best.
For text over images, add a solid or darkened panel behind the words. A photo changes with cropping, so an overlay is more reliable than hoping the picture stays dark in the right place.
Don't let color carry meaning alone
Color vision differences are common, especially between certain reds and greens. A form that marks errors only with a red border, or a chart whose lines differ only by hue, leaves some people guessing.
Add a second cue:
| Instead of color only | Add |
|---|---|
| Red field border | Icon and a text message |
| Green and red status dots | Words such as "Online" and "Offline" |
| Colored chart lines | Different dash patterns and direct labels |
| Blue links in body text | An underline |
| Highlighted required fields | The word "required" |
A grayscale preview, available in some developer tools and operating system settings, quickly shows what disappears without hue.
Dark mode and very high contrast
Dark themes need their own checking. A gray that passes on white may fail on near-black, and saturated colors can appear to vibrate against dark surfaces. Many designers use off-white text on very dark gray, which keeps a strong ratio with less glare than pure white on pure black. Preferences differ, so offer a choice where you can and follow the system setting with the prefers-color-scheme media query.
:root { --text: #1a1a1a; --bg: #ffffff; }
@media (prefers-color-scheme: dark) {
:root { --text: #e8e8e8; --bg: #121212; }
}
body { color: var(--text); background: var(--bg); } Some people use forced colors modes, such as Windows contrast themes, which replace your palette. Don't encode borders or focus outlines only as shadows or background images, since those can vanish. Test with the mode on.
Type choices that affect reading
Contrast alone won't rescue small, cramped text.
Set sizes in relative units such as rem so user preferences are respected. A base size around 16 pixels is a common starting point, and many sites go larger for long reading. Keep lines of body text to roughly 45 to 90 characters. Left-aligned text is generally easier than justified text, which can create uneven gaps. Reserve all capitals for short labels.
WCAG also requires that text can be enlarged to 200 percent without losing content, that pages reflow on narrow widths, and that layouts survive users increasing line height and letter, word and paragraph spacing. Fixed-height boxes are the usual reason they don't.
Fixing a failing color without losing the brand
Most failures are mid-tones: a light gray for secondary text, white words on a bright orange, green or light blue button, or a pale link on a tinted card. You rarely need a new identity to fix them.
- Keep the hue and lower the lightness until the pair passes. A slightly deeper shade usually still reads as the brand color.
- Swap the roles. Dark text on a bright button often passes where white text fails.
- Make the text qualify as large and bold if it's a short heading or button label, then confirm it clears 3:1.
- Add an underline, border or icon so that identification doesn't depend on a subtle color shift.
- Retire the shade for text and keep it for decoration.
After changing a color, recheck its neighbors. Darkening a background to rescue white text can break a dark icon that sits on the same surface. States matter too: a hover style that lightens a button may push the label below the threshold at the moment someone is aiming at it.
Transparency, gradients and thin lines
Semi-transparent text has no single color of its own. Its effective color depends on what's behind it, so measure the blended result against the worst background it can meet. The same goes for frosted panels and text over video.
On gradients, test the end where contrast is lowest, and remember that the text may sit in a different spot on a narrow screen than on a wide one.
Anti-aliasing softens thin strokes, so a very light font weight can look paler than its stated color. If body text uses a light weight, move to regular. Fine one-pixel input borders in pale gray are a frequent non-text contrast failure; darkening them makes forms noticeably easier to use.
Help readers adjust
People change settings for good reasons: larger default text, zoom, reader mode, a high contrast theme or an inverted display. Your job is to avoid fighting them. Don't disable pinch zoom in the viewport tag, don't set sizes in a way that ignores the browser's default and don't put essential words in images.
If you offer your own theme switch or text size control, treat it as an extra. Remember the choice, make the control easy to find and keep the page working with system settings when no choice has been made.
Contrast formulas have limits
The WCAG 2 ratio is a practical, testable rule, but it doesn't model perception perfectly. It can approve some pairs that feel hard to read, particularly in dark themes, and reject a few that look fine. Newer methods are being researched and discussed. Until a different method is part of the standard you must meet, use the published ratios as the floor and your own testing as the check above it.
Make it stick
Define color tokens with approved pairings in your design system, so people choose "text on surface" rather than picking hex values. A palette generator can propose shades, but verify each pair you actually use. When a brand color fails for text, keep it for large shapes and use a darker variant for words.
Then look at the real thing: on a phone outdoors, on a dim cheap monitor and zoomed in. Ask someone older than the design team to read it. The habits here fit within the wider approach in web accessibility explained, and they pair naturally with visible focus styles from keyboard navigation and focus and the type loading advice in web fonts. Clear writing, covered in how to write web content people will read, completes the picture.
Common questions
Does my logo need to meet the ratio?
Logos are exempt from the text contrast rule. A readable version for small sizes and varied backgrounds is still worth having.
Is black on white always best?
It has the highest ratio, but some readers prefer slightly softer combinations. Any pair comfortably above the threshold is reasonable.