Help for the Color Contrast Tool

Back to the tool

About colors on the web

Two-color mode 🔗

Evaluate the contrast between two colors. You can specify the colors:

Screenshot: Two settings, labeled color #1 and color #2. Both are followed by # and then a text-input box (with RGB hex-triplets) and then the Safari's built-in color-picking widget.

The widget will provide:

In addition, there will be a permanent link to your current color selections and results. Switching to color/hue mode will preserve color #1, while the hue of color #2 will be used for the hue.

Color/hue mode 🔗

In this mode, you provide:

Screenshot: A widget in which the user can enter a color as a hex triplet, and specify the hue for a second color. The widget then shows how well the first color contrasts with various HSL combinations involving the given hue.

In response, the widget will provide a table with colors using the 172 = 289 combinations of the specified hue with various values for saturation and lightness. (Some colors will be repeated, because a lightness of 0% always produces black, while lightness of 100% always produces white.) The table will show the contrasting color along with these other colors. The table will give the contrast ratio and the WCAG compliance ratings for this color combo.

Hovering over a cell of the table will show the hex code of second color as an RGB hex triplet. Clicking on (or touching, etc.) a cell will take you to the two-color mode with that particular color combo as the two colors.

In addition, there will be a permanent link to your current color and hue selections and results. Switching to two-color mode using the button at the top will use the contrasting color as color #1, while color #2 will be the closest RGB hex triplet corresponding to the color with the specified hue, saturation 50%, and lightness 50%.

Concepts 🔗

About colors on the web

Relative luminance 🔗

The relative luminance of a color is an approximation of how bright that color will be perceived by the human eye. This takes into account human eye's different sensitivity to various colors. (The eye is most sensitive to green, less sensitive to red, and least sensitive to blue.) Relative luminance is measured on a scale from 0 to 1.

For example:

( W3C WCAG description of relative luminance)

Contrast ratio 🔗

The contrast ratio between two colors measures how well the colors contrast. Naïvely, one might define it as the ratio of the two colors' relative luminances. However, black has a relative luminance of zero, so that won't work. Instead, the contrast ratio is defined as L 1 + 0.05 L 2 + 0.05 , where L1 is the relative luminance of the lighter color and L2 is the relative luminance of the darker color. Contrast ratios range from 1 to 21, with higher values representing better contrasts.

For example:

( W3C WCAG description of the contrast ratio)

W3C WCAG compliance 🔗

The World Wide Web Consortium (W3C) has published Web Content Accessibility Guidelines (WCAG). Regarding color contrasts:

For example: