Skip to content
easeweb
Search topics

Missing focus indicators

A reset removes the outline and leaves no visible replacement.

WCAG 2.2
SC 2.4.7AA
Required by
Section 508 · EN 301 549 (EU)
Broken
The accessibility problem illustrated: Motor:Am I on Save?
01

The problem

Keyboard users can't see where they are on the page

02

Try it

Press Tab and watch the buttons

Press Tab to move through the buttons on both backgrounds.

Broken Can you fix this?

BrokenA reset with nothing in its place

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Bring back a focus ring that shows on every surface

Before
BrokenA reset with nothing in its place
*:focus {  outline: none;}.brand-button:hover {  background: var(--brand-dark);}
What is wrong2 points
  • Keyboard users can't see where focus is: the reset removes the browser's indicator from every control, and nothing replaces it.
  • A control that takes focus looks just as it did: the hover style responds only to a pointer, not to keyboard focus.
After

A ring for each surface

.brand-button:hover {  background: var(--brand-dark);}.brand-button:focus-visible {  outline: 3px solid var(--focus-ring);  outline-offset: 3px;}/* On the dark banner, switch to a ring that contrasts with it. */.banner .brand-button:focus-visible {  outline-color: var(--focus-ring-on-dark);}@media (forced-colors: active) {  .brand-button:focus-visible {    outline-color: Highlight;  }}
How it is fixed4 steps

Delete the reset rather than overriding it control by control, then add a visible indicator.

  1. Draw the ring on :focus-visible. It shows when focus comes from the keyboard without adding it to every mouse click.
  2. Colour it with a contrast ratio of at least 3:1 against the surface it sits on, the threshold 1.4.11 Non-text Contrast sets for a focus indicator.
  3. On the dark banner, switch to a ring colour that contrasts with it. One colour rarely works on both a light page and a dark banner.
  4. In forced colors, draw the ring in Highlight.

This fixes the Before and passes 2.4.7.

04

Design ideas

Pick the focus colour for every surface, not just one

Three ways to colour focus for buttons on a white page and a dark banner. Press Tab to move through them: two stay visible on both, and one disappears on the banner.

In the design file

  • Draw the focused button on every background it sits on, the white page and the dark banner, not only the one in the main mock-up.
  • Choose one focus colour that reaches 3:1 on every surface, or name one token per surface, such as focus-on-light and focus-on-dark.
  • Write each ring’s contrast ratio against the surface behind it. The example’s mid blue has 4.20:1 on white and 4.29:1 on the banner.

Passes

  • One mid-blue ring for both surfaces A 3px #1c7ed6 ring, dark enough for the page and light enough for the banner: 4.20:1 on white and 4.29:1 on #051827. A colour halfway between the two surfaces lets one token cover both.
  • Outline pill that fills on focus Focus fills the pill with its own line colour: navy on the page, 16.42:1 against white, and white on the banner, 18.00:1 against #051827. Hover only tints it, so focus still looks different from hover.

Fails

  • Brand navy ring everywhereWCAG 2.4.7 One 3px #0d2131 ring for every surface: 16.42:1 on the white page, 1.10:1 on the #051827 banner, where focus disappears. A colour checked only on the page it was designed on fails on the next surface.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Forced colors

0 of 4 checked

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

Limits

This is a starting pattern, not a guarantee for every application. Token names in the snippets are placeholders for your own design tokens. This guide covers focus with no ring at all; for a ring that is there but too thin or faint to find, see ways to draw a focus indicator that passes; for a ring whose colour is too close to the background, low-contrast focus rings against the background; and for a scroll box that Tab never reaches at all, scrollable areas that a keyboard can't scroll. Test the complete journey on your real surfaces.

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.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service