Color and Typography: Building More Legible Text for the Web
Contrast ratios, color blindness, and dark mode — the accessibility rules that govern how text meets color on the web.
Text color and background color affect how easily people can distinguish the words on a page. WCAG defines contrast success criteria for many text presentations, with specific thresholds and exceptions. Meeting a contrast threshold is one part of accessibility; it does not by itself guarantee that every person can read a passage. Pair contrast checks with clear language, usable type size, and testing in the actual interface.
The WCAG Contrast Requirements
WCAG 2.2 Success Criterion 1.4.3 (AA) generally requires a contrast ratio of at least 4.5:1 for text, or 3:1 for large text: at least 24 CSS pixels regular or about 18.66 CSS pixels bold. Success Criterion 1.4.6 (AAA) raises those thresholds to 7:1 for ordinary text and 4.5:1 for large text. Both criteria include exceptions, including incidental text and logotypes. The ratio is calculated from the relative luminance of the foreground and background colors.
The WCAG thresholds are conformance criteria, not a diagnosis of who can or cannot read a particular page. A pair that passes may still be uncomfortable under glare, on a dim display, or at a small size. The Text Contrast Checker on this site calculates a color-pair ratio and compares it with WCAG thresholds; it does not scan a whole page or evaluate every accessibility requirement.
Why Gray Text Fails
Muted gray can look refined beside pure black, but the contrast still needs to be checked. The sRGB color #767676 against white has a ratio of about 4.54:1, just above the 4.5:1 AA threshold for ordinary text; #999999 against white is about 2.85:1 and falls below even the 3:1 large-text threshold. A color choice that looks clear on one display may be harder to distinguish in another environment, so check the actual pair and context.
For equal-channel grays on white, #767676 is approximately the lightest 8-bit gray that reaches 4.5:1; it is not the darkest gray that passes. #595959 is about 7:1 and meets the AAA threshold for ordinary text. These are examples for white backgrounds, not universal gray values: calculate the ratio again whenever the text color, background, opacity, or rendering changes.
Color Blindness and Information Encoding
The National Eye Institute estimates that about 1 in 12 men have color vision deficiency; prevalence varies across populations. If a design uses color alone to distinguish errors, success, or warnings, some users may not be able to tell those states apart. WCAG Success Criterion 1.4.1 says color must not be the only visual means of conveying information, indicating an action, or distinguishing an element.
A practical pattern is to pair color with another cue, such as a clear text label, icon, shape, or line style. An error can use red together with an error message; a chart can use both color and distinct markers. Check that the extra cue is visible and understandable, and do not rely on a color name alone when users need to act on the information.
Dark Mode Considerations
Dark themes change the color pairs and the surrounding visual context. White on black and black on white have the same WCAG contrast ratio, but users may perceive the two presentations differently. Do not assume that a dark theme is automatically more comfortable; test its type size, contrast, spacing, and controls with the intended audience and display conditions.
Some dark themes use off-white text on a charcoal background as a visual design choice. For example, #E0E0E0 on #121212 has high contrast, but that palette is not a WCAG requirement and does not suit every product or reader. Calculate each text and background pair, including muted labels, placeholders, links, and disabled states, rather than assuming the main palette covers them all.
Testing Your Contrast
Manual contrast calculation is error-prone because the luminance formula is non-intuitive. A color that looks like it should have high contrast may not, and vice versa. Use an automated tool. The Text Contrast Checker on this site accepts foreground and background colors, displays the calculated ratio rounded to two decimal places, and compares it with AA and AAA thresholds for the selected normal- or large-text size. Its result is a contrast check, not a complete accessibility review.
For a page review, sample text in every theme and state, including hover, focus, error, and disabled states. A pair that passes in light mode can fail in dark mode. Automated tools can find some color pairs, but confirm gradients, transparency, images, and layered backgrounds in the rendered interface. A color checker is one useful step in a broader accessibility review.
Beyond the Minimum
Passing AA is a baseline for the criterion, not proof that a design is comfortable in all conditions. Where the palette allows it, stronger contrast can provide more margin, but it should be checked alongside text size, line length, resizing, and user preferences. A useful target is a page that remains understandable when the display, viewport, or text settings change.
Give an error more than a color
A field turns red, but no text explains what happened.
A linked message describes the correction and a border or icon reinforces the state.
Treat the example as a starting point and test it with the typeface, content, and audience of the page.
A Practical Pattern
a:focus-visible, input:focus-visible {
outline: 3px solid #294b70;
outline-offset: 3px;
}
.muted-copy { color: #45413e; background: #fffdfa; }Replace the illustrative values with the typeface, content, and browser targets used by your project.
Review Checklist
- Measure each foreground and background state.
- Use labels and text as well as color.
- Check focus and forced-colors behavior.
- Test zoom and narrow reflow.