Testing

How to check the contrast ratio of text in Chrome DevTools

6 min read
Mikhail ShaymardanovWeb Quality and Accessibility Expert

To see whether text has enough contrast, inspect it in Chrome DevTools: the tooltip gives its ratio, and the color picker shows whether it passes AA and AAA. On a solid background, that number is right. On a gradient or a photo, overlay or not, it goes missing or comes out wrong. For the real ratio, use the eyedropper on the background behind the letters, then fix the color.

Read, check and fix the ratio


#Where to find the contrast ratio in Chrome DevTools?

DevTools, Chrome's built-in developer tools, shows the contrast ratio of the text you inspect in two places: the Inspect mode tooltip and the color picker. The ratio tells you whether people with moderately low vision can read your text without assistive technology. The minimum threshold makes up for vision of about 20/40, typical around age 80.

To follow along, open the showtimes page of The Fanlight, a small movie theater. Our values come from Chrome 156.

Turn on Inspect mode with Cmd+Shift+C on macOS or Ctrl+Shift+C on other systems, then hover over the text. For the gray line "Subtitled · 1 hr 52 min · Screen 2", the tooltip shows 3.23 on its Contrast row, next to an orange exclamation mark. To freeze the tooltip while you move the pointer, hold Ctrl+Option on macOS or Ctrl+Alt on other systems.

Screenshot: the Chrome Inspect mode tooltip above the gray line “Subtitled · 1 hr 52 min · Screen 2”, with the color #8E8577 and a Contrast row at 3.23.Marker 1. The tooltip's Contrast row: 3.23 and an orange exclamation mark.
In Inspect mode, the tooltip's Contrast rowmarker 1 gives 3.23 for the gray line of “A Summer in Trieste”, with an orange exclamation mark.

#How to tell if the text has enough contrast?

For a verdict, open the color picker. In the Elements panel, on the Styles tab, click the small square to the left of the color value. Only this picker shows a Contrast ratio section. Its "Show more" arrow opens two rows: AA, the minimum, and AAA, the enhanced level. Each gets a green check mark if the text passes, and a red crossed-out circle if it doesn't.

DevTools picks the right AA threshold on its own: 4.5:1, or 3:1 for large text. Large means 24 px and up, or about 18.7 px in bold. The gray line, #8E8577 on #F6F1E7 at 15 px, fails AA at 3.23:1. Borders, focus outlines and icons get no ratio in the picker at all, and their threshold is 3:1 whatever their size: here's how to check them.

WCAG, the web's accessibility guidelines, sets these ratios, detailed in our color contrast guide. In the US, an ADA rule adopts them for state and local government websites. In Europe, the European Accessibility Act's reference standard includes them.

Screenshot: on the left, the “A Summer in Trieste” card and its gray line; on the right, the DevTools color picker open on color: #8e8577, with Contrast ratio 3.23 and the rows AA: 4.5 and AAA: 7.0, each with a red crossed-out circle.Marker 1. The Contrast ratio header, at 3.23. Marker 2. The AA: 4.5 row and its red crossed-out circle.
The color picker gives a ratio of 3.23marker 1 for the gray line, and the AA rowmarker 2 carries a red crossed-out circle: the line fails.

#Why DevTools shows an APCA score?

If the picker shows a percentage and one APCA row in place of the threshold rows, a box is checked in the DevTools Settings. Open them with ? or F1 (Fn+F1 on a Mac) and go to Preferences. In the Elements section, it's the box that starts with "Advanced Perceptual Contrast Algorithm (APCA)".

Chrome 149 made it a regular setting, off by default but switched on for anyone who had turned on the old APCA experiment. Uncheck it to get the ratio back, since that's the number accessibility audits check.


#When the DevTools contrast ratio is not showing or is wrong?

DevTools compares the text with what it finds behind it. With no single background, there's no ratio. Under a semi-transparent overlay on a photo, the ratio runs too high.

#Why the contrast ratio is not showing on a gradient or a photo?

The film club banner, "Thursday film club: every ticket is $5", sits on a gradient: DevTools finds no single background. The picker gives no number, only "No contrast information available". A heading set on a photo gets no ratio either. The same message comes up for a paragraph with a link, like the line "Buy tickets online or at the box office": DevTools measures only elements holding nothing but text.

In those cases, click "Show more", then the eyedropper next to "Pick background color", and click the page right under the letters. Aim for the lowest-contrast spot: the lightest area behind light text, the darkest behind dark text. Keep off the letters, or the eyedropper picks up the text color.

Screenshot: on the left, the banner “Thursday film club: every ticket is $5”, cream on a gradient from brown to orange; on the right, the color picker with no ratio, showing “Pick background color”, the background eyedropper and “No contrast information available”.Marker 1. The Pick background color prompt. Marker 2. The background eyedropper, right of the prompt.
On the film club banner, the picker shows no ratio and asks for the backgroundmarker 1: the eyedroppermarker 2 picks it from the page.

The cream text, #FFF8EC at 20 px, runs over a gradient from brown to orange #D9822B. Under "$5", the eyedropper gives 3.04:1. Each letter needs enough contrast with the background right behind it, so the banner fails AA, even though its dark left end passes easily.

#Why the ratio is too high under a semi-transparent overlay?

On the film's photo, the white showtimes sit on a band of rgba(18, 14, 10, 0.5): a near-black at half opacity. At 17 px, even in semibold (600), that's regular text, so it needs 4.5:1. DevTools shows 19.21:1 and two check marks, because it calculates as if that near-black were opaque and never sees the photo.

The snowy photo shows through and lightens the band. With the eyedropper on the lightest spot behind the letters, DevTools shows 3.75:1, below the AA threshold. In a wider window, the photo grows and you get 3.8:1.

Screenshot: on the left, a photo of a snowy square with the showtimes “Tonight · 8:30 · 10:45 PM” in white on a gray band at the bottom; on the right, the color picker with Contrast ratio 19.21 and two green check marks.Marker 1. The showtimes “Tonight · 8:30 · 10:45 PM”, white on the semi-transparent band. Marker 2. The Contrast ratio section at 19.21, with a green check mark at AA and at AAA.
Against the snow, the showtimesmarker 1 are hard to read, yet DevTools shows 19.21 and two check marksmarker 2; the eyedropper under the letters gives 3.75:1.

To find a darker overlay that works, try white on more opaque rgba() values in our contrast checker. It handles transparent colors and offers similar colors that pass.


#Fix the color in DevTools, then copy it to your code

The picker suggests a text color that passes. Copy it into your stylesheet: DevTools loses it when you reload the page or DevTools.

On the AA row, click the small square right of the crossed-out circle: the "Use suggested color … to fix low contrast" button. For the gray line, DevTools switches to #736C61 and shows 4.59, and the AA row gets a check mark. It's the same warm gray, only darker. You can also drag the circle in the color area past one line for AA, or past both for AAA.

Screenshot: the color picker after a click on the suggested color, with the value #736c61, Contrast ratio 4.59, a green check mark at AA: 4.5 and a crossed-out circle at AAA: 7.0.Marker 1. The value field, #736c61. Marker 2. The AA: 4.5 row and its green check mark.
Once you click the suggested color, the value becomes #736c61marker 1 and the AA rowmarker 2 gets a green check mark, with a ratio of 4.59.

Copy the value with the picker's color swatch ("Copy color to clipboard"). Until you reload, the Changes panel lists your DevTools edits. To find it, open the Command Menu (Cmd+Shift+P on macOS, Ctrl+Shift+P on other systems), type "changes" and choose Show Changes. Watch the panel's copy icon, though: it copies the whole file, here the HTML page. Paste the new color into your CSS, reload, and check the AA row again.

Screenshot: the DevTools Changes panel, with the line color: #8e8577 highlighted in red, the line color: #736c61 highlighted in green, and the copy icon at the top of the file.Marker 1. The deleted line color: #8e8577; and the added line color: #736c61;. Marker 2. The Copy file … to clipboard icon.
The Changes panel shows the old color and the new onemarker 1; the copy iconmarker 2 copies the entire edited file.

On a gradient or a photo, the suggested color holds only for the spot you picked. In that case, rework the background with a darker overlay or a softer gradient (see text over images), then measure again.


Before you code a new color pair, try it in our contrast checker. To check The Fanlight's whole showtimes page at once, run an Includdy scan: it lists the accessibility issues of a page or a component.


Share this article

Frequently asked questions

A small gap comes from the display: DevTools cuts the ratio to two decimals without rounding, so 4.6099 shows as 4.6. A bigger gap comes from the colors being compared. Under a semi-transparent overlay on a photo, for example, DevTools treats the overlay as opaque.

The formula is the same WCAG one, and DevTools blends transparent text into its background first. To compare, paste the two colors from your stylesheet into our contrast checker, which also accepts transparent colors.

Force the state first. On the Styles tab, click :hov and check :hover or :focus, then open the color picker for that state's color.

Text that appears on hover or focus has to meet the same contrast minimum as the rest of the page, and so does the placeholder text inside a form field.