Colors Names

Field guide

Read a contrast ratio without rounding away a failure

The text size, background and exact unrounded ratio all affect the decision.

Choose the actual pair

Measure the rendered foreground and the background immediately behind the text. WCAG compares their relative luminances, giving ratios from 1∶1 for identical colors to 21∶1 for black against white. For a translucent fill, find the composited color over its real background first. A gradient or photo calls for checks where the text encounters the least contrast.

Apply the text threshold

For WCAG AA, ordinary text needs at least 4.5∶1. Large text needs at least 3∶1. The large-text definition includes 18-point regular text and 14-point bold text, equivalent to 24 and about 18.67 CSS pixels respectively. At AAA the thresholds are 7∶1 and 4.5∶1. A logo has a specific exception. Other text near that logo still needs its own assessment.

A borderline gray

Compare #757779 with white. The ratio is about 4.495626∶1. Displaying two decimal places yields 4.50∶1, yet it falls below the normal-text AA threshold. A slightly different choice, #767676 on white, reaches about 4.542225∶1 and passes. Test the full-precision number before formatting it for display.

Check the rest of the interaction

Text contrast settles one question about one pair. Important visual information identifying controls and their states can require 3∶1 against adjacent colors under the non-text contrast criterion. When color carries meaning, add another cue such as an error message or a labeled pattern. Read the applicable criterion for its exceptions and test the actual control states.

Check a contrast pair

Sources