Step by Step

Non-text contrast (WCAG 1.4.11): how to check a border, focus indicator or icon when DevTools shows no ratio

7 min read
Mikhail ShaymardanovWeb Quality and Accessibility Expert

A developer who clicks the color of a border in Chrome DevTools gets no contrast ratio at all. The color picker only calculates one for the color property of text. For a border, a focus outline or an icon, the element's color comes from the code and the background's from the eyedropper. A contrast checker then judges the pair against 3:1, the minimum WCAG 1.4.11 sets for non-text contrast.

Measure what DevTools doesn't


#Non-text contrast (WCAG 1.4.11): which colors to compare for a border, focus indicator or icon

Non-text contrast compares a piece of interface, or an icon, with the color right next to it. The minimum is 3:1.

It covers whatever shows that a UI component is there, its state, such as keyboard focus, and any icon that carries information. Below 3:1, someone with low vision can miss the control entirely. The rule is success criterion 1.4.11 of the Web Content Accessibility Guidelines (WCAG). It sits at Level AA, the level laws point to. The Americans with Disabilities Act rule covering state and local government websites requires WCAG 2.1 at that level, this criterion included. In Europe, EN 301 549, the standard companies use to show they meet the European Accessibility Act, requires it too.

The color that counts is the one touching the element from the outside. The W3C, which writes these guidelines, uses a white input with a dark border on a white page: the adjacent color there is the white outside the field. On the Thistle Bindery newsletter form, that makes four pairs. The email field's border and its focus outline, drawn 2 px further out, both sit on the cream page. The two icons sit on the white of their buttons.

Screenshot: the Thistle Bindery home page, with a photo of three notebooks with marbled covers, the list of notebooks and their prices, then the Bindery Letter panel, its sign-up line and an empty field with a light blue outline, next to the Sign up button.Marker 1. The email field in focus, with its gray border and light blue outline. Marker 2. The search button, a gray magnifier on white. Marker 3. The close button, a gray X on white.
The email field's border and outlinemarker 1 are measured against the cream page #f6f4ef; the magnifiermarker 2 and the Xmarker 3 against the white of their buttons.

#When a form field border needs 3:1?

A field's border only gets judged when it's the one thing showing the field, the only case where the W3C asks it for 3:1. On the demo, it is. We took the label out on purpose so the border would stand alone. Nothing is typed inside, and the field's white barely stands out from the page, at 1.10:1.

A real form keeps its "Email address" label on screen, though. The demo names the field only in code, for screen readers (aria-label), which tells nothing to someone looking at an empty box. With that label in place, the border would no longer need 3:1.

Everyday cases fall outside the threshold too: a disabled element, or an icon whose meaning is spelled out next to it. The same goes for the browser's default focus outline left as is, which only has to stay visible (the other exceptions).

Focus visible: how to style the focus indicator in CSS

#How to check non-text contrast in Chrome DevTools?

DevTools only works out a contrast ratio for the color property. It still shows both colors of a border or an icon, and the verdict at 3:1 comes from a contrast checker.

#Why the color picker shows no contrast ratio for a border?

It all starts with a tiny square. On the Styles tab, the field's border has a color swatch in front of #c9c6be, like a text color. We clicked it, and the usual color picker opened without its Contrast ratio row.

The focus outline gets the same silence, and so does an SVG icon, even one that takes its color from its button. The outline's rule only shows up once the :hov button turns on the focus state. The reason lives in DevTools' source code: the contrast section is only added to a property named exactly color. We ran these tests in Chrome 156.

Screenshot: on the left, the end of the notebook list, then the Bindery Letter panel and its email field; on the right, the DevTools Styles tab with the .field rule and the color picker open on #c9c6be, showing the color area, the eyedropper and the hex value.Marker 1. The declaration border: 1px solid #c9c6be and its color swatch. Marker 2. The open color picker, with no contrast section.
Opened from the swatch of the border #c9c6bemarker 1, the pickermarker 2 shows the color without any Contrast ratio row.

#Where to read the border or icon color?

  1. Read the element's color on the Styles tab, in its CSS. An icon that inherits its button's color shows it in the "Inherited from" section.
  2. Pick the background with the eyedropper, right next to the element: with the picker open, press C, then Esc to leave (the same move, step by step, for text). The click also replaces the color of the line you opened, until the page reloads. When the CSS sets the background, Styles shows it too, like the button's #ffffff.

Why not drop the eyedropper on the icon itself? The W3C asks for the color in the code, because the screen's edge smoothing (anti-aliasing) can draw a thin line much paler than it is. We counted on the demo's magnifier: 67 of its 133 pixels come out lighter than the code color, down to 1.23:1 where the code gives 2.61:1. On a standard display, then, the eyedropper lands on a pixel that's too pale about every other time. On a high-density screen, the share changes. On the field's border, only the rounded corners fade.

#Compare the two colors in a contrast checker

That leaves the math. Paste the element's color as the text color of a contrast checker, the background as the background color, and judge the ratio at 3:1. On the demo, the field's border against the page gives a contrast ratio of 1.55:1.

Screenshot: a contrast checker with #c9c6be as the text color and #f6f4ef as the background color; the red panel shows 1.55:1 and three failing rows: Normal text, Large text and Interface.Marker 1. The ratio shown, 1.55:1. Marker 2. The Interface row, marked Fail.
The border #c9c6be on the page #f6f4ef gives 1.55:1marker 1, and the Interface rowmarker 2 marks it as failing at 3:1.
How to check the contrast ratio of text in Chrome DevTools

#Non-text contrast examples: the verdict on a real form, and the fix

On the demo form, the field's border, its focus outline and the search magnifier all fall short of 3:1, while the close button's X passes. The outline's verdict depends on the standard. For the W3C, the dark text cursor blinking in the field already shows focus, as long as the cursor itself reaches 3:1. France's RGAA, the standard French sites are audited against, is stricter: focus has to change the field's outline or background, at 3:1 or more.

#The verdict, element by element

To fix: below 3:1 on the Thistle Bindery form
ElementElement, then backgroundRatio
Email field border#c9c6be
#f6f4ef
1.55:1
Field focus outline#9ec5fe
#f6f4ef
1.61:1
Search magnifier#a3a09a
#ffffff
2.61:1
Already passing: 3:1 or more on the Thistle Bindery form
ElementElement, then backgroundRatio
Close X#8f8b84
#ffffff
3.39:1

#Icon contrast: SVG or icon font, and what the DevTools verdict is worth

The X is the one that caught us off guard. Written as a character, the way an icon font does it, it makes DevTools treat its button as text. The picker does show "Contrast ratio 3.39". Then it puts a red crossed-out circle on "AA: 4.5", the threshold for regular text, and suggests darkening the X to #78756f. For the W3C, the "X" of a Close button is a non-text symbol, judged at 3:1, so at 3.39:1 the X passes.

The DevTools verdict follows the font size. At 24 px, which DevTools counts as large text, the same X gets a check mark on "AA: 3.0". The non-text contrast threshold doesn't depend on any size.

Screenshot: on the left, the Bindery Letter panel and its close button with an X; on the right, the DevTools color picker open on #8f8b84, with Contrast ratio 3.39 and the rows AA: 4.5 and AAA: 7.0 each marked with a red crossed-out circle, above the .close rule at 20 px.Marker 1. The contrast ratio shown, 3.39. Marker 2. The AA: 4.5 row and its red crossed-out circle.
DevTools shows 3.39marker 1 for the close X and judges it against 4.5marker 2, the threshold for 20 px text; at 3:1, it passes.

The SVG magnifier ends up with the same text verdict, by a longer road. The picker for its button's color first says "No contrast information available". Its contrast section still has a second eyedropper, next to the "Aa" preview, for the background. One click on the button's white, and 2.6 shows up, judged against 4.5 as well. That number is right, since DevTools computes it from the CSS color. Only the verdict needs redoing at 3:1.

#Fixing each color

Darken each color without changing its hue, up to the first shade that reaches 3:1, then copy it into the stylesheet: DevTools forgets its edits on reload.

Avoid

Screenshot: the Thistle Bindery header with its pale gray magnifier, then the Bindery Letter panel and its empty email field with a pale gray border, surrounded by a very light blue outline.Marker 1. The email field, its border #c9c6be and its outline #9ec5fe. Marker 2. The magnifier #a3a09a on its white button.
.field { border: 1px solid #c9c6be; }
.field:focus-visible { outline: 2px solid #9ec5fe; }
.search { color: #a3a09a; }

Correct

Screenshot: the same header and panel, with the magnifier and the field border in a darker gray and the focus outline in a strong blue.Marker 1. The email field, its border #938d7e and its outline #3e8bfd. Marker 2. The magnifier #98948e on its white button.
.field { border: 1px solid #938d7e; }
.field:focus-visible { outline: 2px solid #3e8bfd; }
.search { color: #98948e; }
After the fix, the field's border reaches 3.01:1 against the pagemarker 1. Its outline and the magnifiermarker 2 both reach 3.02:1, and the X keeps its color.

We stopped just above 3 on purpose, because the threshold doesn't round: per the W3C, 2.999:1 fails. For a 1 px border or a thin-stroked icon, though, the W3C recommends a thicker line or a margin above the minimum, since edge smoothing fades thin shapes. The field had another way out. A background at 3:1 against the page would show it on its own, and its border would have no threshold.

The X stays as it was. The color DevTools suggested, #78756f, climbs to 4.59:1, darker than an icon needs.


To try a border or icon color before coding it, paste it with its background into our contrast checker: the Interface row gives the verdict at 3:1.


Share this article

Frequently asked questions

No, as long as it isn't what identifies the component. The W3C counts a drop shadow, or a dark line between two contrasting backgrounds, as part of whichever neighboring color is closest in brightness.

A white field on a dark blue #003366 page stands out by its background, so its silver border has no threshold at all. A border only needs 3:1 when nothing else shows where the field is.

In the W3C's own example, yes: the gray #CCC outline reaches only 1.6:1 on white, but the cursor blinking in the field is enough, provided the cursor itself reaches 3:1. France's RGAA is stricter here: it checks that focus changes the field's outline or background, at 3:1 or more.

A button or a link has no cursor. When a site draws its own focus indicator, that indicator has to reach 3:1 against the colors around it (guide to :focus-visible).

No. For the W3C, 3:1 is a hard threshold with no rounding, so 2.999:1 fails. Gray #949494 reaches 3.03:1 on white. Its neighbor #959595 fails at 2.995:1, even though a display rounded to one decimal would show it as a passing three.

DevTools cuts its ratios off without rounding, and our contrast checker never rounds up to a threshold: any reading under 3 is a real fail.