Focus not visible (keyboard:focus-visible)

The keyboard:focus-visible rule flags elements that receive keyboard focus without anything visibly changing. Keyboard users lose track of where they are. The fix is a clear focus indicator via :focus-visible – never outline: none without a replacement.

What the rule means

WCAG 2.4.7 requires that any keyboard-operable interface has a mode where the focus indicator is visible. Browsers show a focus ring by default, so the criterion nearly always fails because a site removes or hides it.

2.4.7 sets no minimum size or contrast for the focus indicator; those come with 2.4.13 Focus Appearance at Level AAA. An outline of at least 2px with 3:1 contrast against adjacent colours is still the safe choice, and also satisfies 1.4.11 Non-text Contrast.

Who is affected

Everyone who can see and navigates by keyboard: people with motor disabilities using a keyboard, switch or mouth stick, and people with low vision using a magnifier who only see part of the page. Without a visible focus they press Enter without knowing what they will trigger.

Why the check fails

  • CSS resets with *:focus { outline: none; } or outline: 0 and no replacement.
  • Removing the "ugly" ring after mouse clicks, which also removes it for keyboard users – exactly what :focus-visible now solves.
  • Custom components (<div role="button">, dropdowns, tabs) with no focus style.
  • Framework overrides, for example box-shadow: none on buttons in dialogs.

How to fix it

/* Before – focus is invisible to everyone */
*:focus { outline: none; }
/* After – visible for keyboard users, calm on mouse click */
:focus-visible {
  outline: 2px solid #005fcc;   /* 5.98:1 on white */
  outline-offset: 2px;
}

/* On coloured or dark surfaces: a two-tone ring */
.btn-primary:focus-visible {
  outline: 2px solid transparent; /* stays visible in Windows contrast themes */
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a;
}

Three notes:

  • :focus-visible shows the ring for keyboard use and usually not when a button is clicked, so there is no reason to remove it globally.
  • box-shadow disappears in forced-colours mode (Windows contrast themes); the transparent outline makes sure a ring still appears there.
  • Check sticky headers and cookie banners: a focus indicator hidden behind another element fails 2.4.11 Focus Not Obscured (Minimum).

How to test it manually

  1. Load the page, click into the address bar and press Tab.
  2. At every step, can you see immediately where focus is – on light, dark and coloured surfaces?
  3. Repeat inside open dialogs and menus, and at mobile width.
  4. In Chrome DevTools › Rendering, emulate "forced-colors: active". Is focus still visible?

2.4.7 Focus Visible, Level AA. Related: 2.4.11 Focus Not Obscured (Minimum), Level AA, new in WCAG 2.2, and 1.4.11 Non-text Contrast.

How Reviseberg reports it

This rule does not come from axe-core: a rules engine doesn't press keys, so it can't see what happens on focus. Reviseberg's keyboard agent walks the journey you choose with real key presses in Chromium. Before the first key it records how every focusable element is drawn; at each Tab step it compares the focused element – and its ::before, ::after and parent, where design systems often put the ring – against that record: outline, shadow, border, background, text colour and underline. If nothing changes, it reports: "Nothing about this element changes when it takes focus." If nothing changes but the element already draws an outline or a shadow, the agent cannot tell the indicator from the design, and marks the step for a person to look at instead of guessing.

Each finding comes with the selector, its step in the keystroke trail and a cropped screenshot. In the issue list the rule appears with its severity, WCAG 2.4.7, the number of pages and the points a fix gets you back. The agent tests the journey you define; it does not reach elements outside it.

  • undefined – focus lands on an element nobody can see.
  • undefined – focus cannot leave an element.
  • undefined – text that does not stand out from its background.

Run the keyboard agent on your site – free report

Frequently asked questions

Can I use outline: none?

Only if you give the same elements a different, clearly visible focus style. The simplest route is your own style on :focus-visible.

What is the difference between :focus and :focus-visible?

:focus matches whenever an element has focus, including after a mouse click. :focus-visible matches when the browser judges a visible indicator useful – mainly for keyboard use.

How visible does focus have to be?

WCAG 2.4.7 sets no measurements. At least a 2px outline with 3:1 contrast to its surroundings is a sensible minimum; the exact requirements are in 2.4.13 (Level AAA).

Why doesn't axe-core catch this?

axe-core inspects the page but doesn't press keys. Whether anything visibly changes on focus only shows up when you test with a real keyboard – by hand or with an agent.

Sources

  1. W3C, Understanding SC 2.4.7 Focus Visible – https://www.w3.org/WAI/WCAG22/Understanding/focus-visible
  2. W3C, Understanding SC 2.4.13 Focus Appearance – https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance
  3. W3C, Understanding SC 2.4.11 Focus Not Obscured (Minimum) – https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum
  4. MDN, :focus-visible – https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible
  5. MDN, forced-colors – https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors

See what a scan finds on your site

One page in about thirty seconds, no email needed. The full report covers up to 100 pages and a keyboard journey.