WCAG Encyclopedia

2.4.7 · OperableLevel AA

Focus Visible

Keyboard focus has to be visible. Removing the outline because it is ugly is the single most common accessibility failure on the web, and it makes a site unusable rather than merely awkward.

Principle
Operable
Guideline
2.4
Level
AA
In WCAG since
2.0
Number
2.4.7

Broken, then fixed

The same interface twice: first with the mistake, then with the smallest change that fixes it.

Broken: The outline was removed and nothing replaced it.
NameEmailCard

outline: none with no substitute. Focus is somewhere; the reader cannot see where. Tabbing becomes guesswork and typing goes into a field they cannot identify.

Fixed: A ring with its own contrast and an offset.
NameEmailCard

Restyling the ring is fine; removing it is not. Give it 3:1 against its surroundings and an outline-offset so it does not disappear into a dark control — and use :focus-visible so it appears for keyboards without following every mouse click.

What changed in the code

The fix as a diff: removed lines are marked with a minus, added lines with a plus.

Markup diff — buttons.css
removed: button:focus { outline: none; }
added: button:focus-visible {
added:   outline: 3px solid var(--focus);
added:   outline-offset: 2px;
added: }

The CSS rule this page uses on every interactive element, verbatim.

Watch it happen

These demos play the failure out over time. They are silent and captioned, and you can pause or scrub at any point.

Name on cardCard numberExpirySecurity codePay £48.00

Tab order not started

CaptionA checkout form, nothing focused yet.
0:00 / 0:14CC onSilent · looping
Name on cardCard numberExpirySecurity codePay £48.00

Tab order not started — invisible

CaptionThe same form, with focus styles removed in CSS.
0:00 / 0:14CC onSilent · looping

How to test

Check your own interface against 2.4.7, one step at a time.

  1. Click in the address bar and press Tab through the whole page. At each stop, check that you can see which element has focus without moving the mouse.
  2. Note any element where focus seems to vanish: nothing changes on screen, or the only change is too faint to spot.
  3. Repeat inside every menu, dialog, tab set and custom widget, using the arrow keys where the widget expects them.
  4. Search the stylesheets for outline: none, outline: 0 and styles on :focus. Check that each one that removes the browser outline puts a visible style in its place.
  5. Repeat the Tab pass in dark mode and with a Windows contrast theme turned on, where a focus style made only of a background colour or a shadow can disappear.

Common questions

Does the browser’s default focus outline pass 2.4.7?

Yes, in most cases, as long as nothing on the page removes it or hides it. Check it against your own colours, though: a default outline can be hard to see on some backgrounds.

Does 2.4.7 set a minimum size or contrast for the focus indicator?

No. 2.4.7 asks only that the indicator is visible. 1.4.11 Non-text Contrast asks that it stands out from its background, and 2.4.13 Focus Appearance, at Level AAA, sets its size.

Can I show the focus ring only to keyboard users with :focus-visible?

Yes. 2.4.7 asks for a visible indicator when the page is used from the keyboard, and :focus-visible gives exactly that while hiding the ring after a mouse click.

Try it yourself

A lab is a small working piece of interface that you change yourself. Read its steps, use the controls under it, and watch the verdict line at the bottom: it says whether the criterion passes or fails as you go. Reset puts it back.

Try it: style your own focus ring

How to use this lab

  1. Goal. Style a focus ring on a dark Save button so it can still be seen.
  2. The controls. The Ring thickness slider sets how thick the ring is, from none to 6px. The Gap from the button slider sets the space between the button and the ring, from touching to 6px. The options under “Ring colour” pick Blue, Black, Mid grey or Yellow, and the results give the ring’s contrast against each colour it touches.
  3. Try this. The lab starts with a blue ring 2px clear of the button. Drag Gap from the button to touching, then try Black and Yellow. Then drag Ring thickness to none.
  4. What it means. 2.4.7 passes when the ring reaches 3 : 1 against everything it touches: the white page and, with no gap, the dark button too. It fails when the ring is lost against either, or there is no ring, because keyboard users can’t see where they are. The verdict line under the lab says which.
Ring colour
  • 6.70:1 against the pageStands out: needs 3:1 (AA · 1.4.11)

2.4.7 passes

Also in guideline 2.4

Criteria in the same guideline often fail together.