# Low-contrast focus rings against the background

Source: https://easeweb.dev/learn/focus-ring-contrast
Topics: Colour and contrast > Controls and icons have enough contrast (WCAG 1.4.11)
The fix: Give the ring 3:1 against whatever is next to it on each surface. Either set a ring colour per surface, draw a two-tone ring that carries its own white on both sides, or, on a coloured band, draw the ring inside a light button, on its own fill.
Test with: contrast measurement, keyboard, zoom, forced colors
References: https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html https://www.w3.org/WAI/WCAG22/Techniques/css/C40 https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

## What happens

A store has a white header with its menu links, and under it a blue band, "Free delivery this week", with two white buttons. Every link and button shows a focus ring when you Tab to it, so focus is never missing. It is hard to see in one of two common ways.

In the first, the ring is the text colour at half strength, a pattern some shop themes use. On the band, where the text is white, the ring is a light blue-grey that stands out well enough. In the white header, where the text is a dark grey, it comes out as a pale grey hairline around the link.

In the second, the ring is the brand blue. In the header it is clear. Around the band's buttons it sits on the band's own deep blue, and you have to look hard to tell which button has it.

## Why it fails

WCAG 1.4.11 Non-text Contrast asks for 3:1 between the visual information needed to identify a state, which includes the focus indicator, and the colours next to it. A ring drawn outside a control sits on the surface around the control, so that surface is what it is measured against. A ring drawn inside the control is measured against the control's own fill.

- The half-strength ring is `rgb(67 67 67 / 0.5)`. Blended with the white header, it is `#a1a1a1`, at 2.58:1. With near-black text the same pattern can pass, which is why it goes unnoticed: the ring is only as strong as the text colour it is taken from, and a softer grey for the text drops the ring under 3:1.
- The brand ring is `#1a4fd0`. It is 6.83:1 on the white header, but on the `#12348f` band it is 1.61:1.

Both rings were checked against one surface only, if at all: the first against a text colour that later changed, the second against the white page it was designed on.

## Who is affected

The same happens to anyone on a glossy phone screen in daylight, or a dim laptop, where a low-contrast ring is the first thing to go.

## What automation and AI miss

Scanners that read the stylesheet, such as axe, don't focus anything, so they never see a focus ring. The audit does: it focuses up to 25 controls on each page, compares a picture of each before and after, and measures the strongest change against the colour that was there before. That finds both Befores here, the pale grey on white and the blue on the band. A control that only appears later (in a menu, a dialog or the next slide) is not reached, and a ring only a hover state draws is not measured. A ring picked in a design tool or written by an AI may be checked only against the page colour in the mock-up, which is how the brand ring passes on white and fails on the band.

## Before: a ring in the text colour at half strength

```css
:root {
  --ink: 67 67 67;
}
.sale-band {
  --ink: 255 255 255;
  background: #12348f;
}
.site-header,
.sale-band {
  color: rgb(var(--ink));
}
.sale-band .button {
  background: #fff;
  color: #12348f;
}
:focus-visible {
  /* The text colour at half strength */
  outline: 2px solid rgb(var(--ink) / 0.5);
  outline-offset: 2px;
}
```

- The ring takes its colour from the text, at half opacity, so its contrast depends on how dark the text is.
- In the white header it blends to `#a1a1a1`, at 2.58:1 against the white around it.
- On the band it blends to `#899ac7`, at 3.92:1, so the fault shows only on white.

## Before: a brand-blue ring that passes only on white

```css
:root {
  --ink: 67 67 67;
}
.sale-band {
  --ink: 255 255 255;
  background: #12348f;
}
.site-header,
.sale-band {
  color: rgb(var(--ink));
}
.sale-band .button {
  background: #fff;
  color: #12348f;
}
:focus-visible {
  /* The brand blue */
  outline: 2px solid #1a4fd0;
  outline-offset: 2px;
}
```

- The ring is 6.83:1 on the white header, so it was signed off there.
- Around the band's white buttons, the ring sits on the `#12348f` band, at 1.61:1.

## After: a ring per surface

```css
:root {
  --ink: 67 67 67;
  --focus-ring: #1a4fd0;
}
.sale-band {
  --ink: 255 255 255;
  --focus-ring: #fff;
  background: #12348f;
}
.site-header,
.sale-band {
  color: rgb(var(--ink));
}
.sale-band .button {
  background: #fff;
  color: #12348f;
}
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
```

1. Add a `--focus-ring` token, solid and not translucent, set to the brand blue on the page: 6.83:1 against white.
2. Set the token again on the band, to white: 10.97:1 against `#12348f`.
3. Draw the ring from the token, so each surface gets the colour checked for it.

This fixes both Befores and passes 1.4.11 on the two surfaces set here. Every new surface, such as a dark footer or a coloured card, needs its own value and its own check.

## After: a two-tone ring

```css
:root {
  --ink: 67 67 67;
}
.sale-band {
  --ink: 255 255 255;
  background: #12348f;
}
.site-header,
.sale-band {
  color: rgb(var(--ink));
}
.sale-band .button {
  background: #fff;
  color: #12348f;
}
:focus-visible {
  outline: 2px solid #1a4fd0;
  outline-offset: 2px;
  /* White on both sides of the blue */
  box-shadow: 0 0 0 6px #fff;
}
```

1. Draw the ring in the brand blue, solid, 2 pixels outside the control.
2. Add a white `box-shadow` that reaches past the ring. It fills the gap inside the ring and shows again outside it, so the blue always has white on both sides, at 6.83:1.
3. On the band, the white halo is what meets the band: 10.97:1 against `#12348f`. On the white header the halo blends into the page, and the blue against white does the work.

This fixes both Befores and passes 1.4.11 with one rule, on any surface whose colour contrasts with either the blue or the white. A contrast theme removes the shadow but keeps the outline.

## After: a ring inside the button, on its own fill

```css
:root {
  --ink: 67 67 67;
}
.sale-band {
  --ink: 255 255 255;
  background: #12348f;
}
.site-header,
.sale-band {
  color: rgb(var(--ink));
}
.sale-band .button {
  background: #fff;
  color: #12348f;
}
:focus-visible {
  outline: 2px solid #1a4fd0;
  outline-offset: 2px;
}
/* On the band, draw the ring inside the white button */
.sale-band .button:focus-visible {
  outline-offset: -5px;
}
```

1. Draw the ring in the brand blue, solid, 2 pixels outside the control: 6.83:1 against the white header.
2. On the band, move the ring inside the button with a negative `outline-offset`. It now sits on the button's white fill, 6.83:1, and never touches the band.

This fixes both Befores and passes 1.4.11 for the band's buttons, but only while each control on the band has a light fill of its own. A text link on the band, or an outlined button with no fill, would put the ring back on `#12348f` at 1.61:1. Give the button room for it: the ring takes the 5 pixels inside its edge, so keep the padding larger than that.

## Which option to use

All three pass 1.4.11 on this page. The ring per surface keeps one clean brand colour and costs a token value and a check for every surface the components sit on. The two-tone ring is one rule for every surface that contrasts with either the blue or the white, at the cost of a heavier look. Technique C40 takes the same idea further: with its two colours 9:1 apart, such as white and a near-black, every possible background contrasts with one of them. The ring inside the button suits a band whose controls are all light buttons, and it needs no colour of its own, but it covers only those buttons; anything else on the band still needs a ring per surface or the two-tone ring. Choose by how many surfaces your controls sit on, and whether editors can add new ones.

## Implementation decisions

Where the ring sits decides what it is measured against. An outline with a positive `outline-offset` sits on the surface, so a brand-coloured button on a white page can use a brand-coloured ring: the ring is measured against the white, not the button. A ring that straddles the control's edge, partly inside and partly outside, needs 3:1 from only one of its two parts. A ring inside the control, as some themes draw for links in a header or arrows in an announcement bar, is measured against the control's fill.

A translucent ring, such as a colour at half opacity or a framework's soft glow at a quarter of the brand colour, has no fixed contrast: it blends with what is under it. Measure the colour it ends up as, on each surface, or make the ring solid. The same goes for a ring set as a `box-shadow` alone, which a contrast theme also removes; keep an outline, as [high contrast mode hiding focus, icons and selections](/learn/forced-colors) explains.

A white halo or a ring outside the control can be cut off by `overflow: hidden` on a parent, such as a carousel track or a scrolling row of cards. Leave room around the control, or use the inside ring there. A dark theme needs its own ring values too, as [dark mode with faint grey text and icons](/learn/dark-theme-contrast) shows.

This guide is about the ring's colour against what is next to it. A control with no ring at all is [missing focus indicators](/learn/visible-focus), and a ring too thin to find, or too close to the colour it replaces, is the stricter AAA test in [focus rings too thin or faint to spot](/learn/focus-appearance). Field borders, checkboxes and icons are in [low-contrast form fields, checkboxes and icons](/learn/non-text-contrast).

## Verify the fix

1. Tab through every control in both directions, on every surface it sits on: the header, coloured bands, cards, the footer and each slide.
2. With a contrast checker, measure the ring as drawn against the colour next to it, the surface for a ring outside the control and the fill for a ring inside, and confirm at least 3:1 on each surface.
3. Zoom to 200% and confirm no parent clips the ring or its halo.
4. Turn on a contrast theme, and confirm the focused control is still outlined.

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the theme tokens, the surfaces or shared component styles change.

## Limits

This is a starting pattern, not a guarantee for every application. The colours and token names are examples; measure your own ring on your real surfaces. A ring that reaches 3:1 can still be hard to find if it is thin, and 2.4.13 asks for more, as the focus appearance guide explains. Test the complete journey with people who rely on the ring.

---

Get this guide in your coding agent: MCP https://easeweb.dev/mcp (setup at https://easeweb.dev/services/developers)
