Keyboard focus / WCAG 2.1 AA

Invisible Keyboard Focus: Finding the Barrier No Scanner Shows

A keyboard user cannot follow what they cannot see. When the focus indicator is missing or too faint, the page works for the mouse and fails for everyone else — and most automated scores stay silent about it.

Run a visual focus check

The barrier

Why Outline None Breaks Keyboard Navigation (SC 2.4.7)

WCAG 2.1 success criterion 2.4.7 (Focus Visible) requires the focus indicator to be visible wherever a control has keyboard focus. The most common way a site fails it is a single line of CSS:

a:focus { outline: none; }

After that line, a sighted keyboard user tabs into the page and gets nothing to look at: no ring, no highlight, no way to tell which link or button is about to activate. Enter still works, so focus silently sits somewhere the user cannot see — forms get submitted from the wrong control, dialogs close without warning, and the page reads as broken even though every click handler is intact.

CSS resets are the usual culprit: a blanket * { outline: none; } applied for looks, or a focus style removed because it clashed with the design and never replaced. If you inherit a stylesheet, search it for outline: none and outline: 0 before you audit anything else.

The full list of what must be checked — including the checkpoints automation can settle on its own — lives in the WCAG 2.1 AA checklist.

Three states

How Computer Vision Tests Focus Indicators (Visible, Weak, None)

A screenshot of a focused control and a screenshot of the same control unfocused are pixel-diffed. If the two images are identical, nothing on the page moved, lit up or grew a ring — the state is NONE. If a handful of pixels changed but the mark is too faint to survive the surrounding design, the state is WEAK. A clear, high-contrast ring that follows every Tab stop is VISIBLE. Every Tab stop is screenshotted focused and unfocused, then reported as VISIBLE / WEAK / NONE with both evidence images attached — no mainstream scanner shows you focus at all.

VISIBLE — the ring you can follow

A ring or highlight with enough contrast against both the control and its background that you could track it through the whole page without hunting for it.

WEAK — present but lost

Technically there, practically invisible: a one-pixel outline the same colour as the border it sits on, or a shadow swallowed by the background. Users who need the cue will not find it.

NONE — identical screenshots

The focused and unfocused images are pixel-for-pixel the same. There is no indicator to strengthen — one has to be added, in CSS, on the element itself.

The evidence

What the Pixel-Diff Proves, and What It Leaves to a Human

The diff is arithmetic, not opinion. For every Tab stop the engine captures the element focused and unfocused, aligns the two images, and classifies what changed:

  • No changed pixels — nothing marked the focused state, so the indicator is NONE. This is a conformance finding against SC 2.4.7, recorded with both screenshots attached.
  • A small, dim cluster of changed pixels — something moved, but it may not clear SC 1.4.11 non-text contrast. The engine stages the pair as needs-review pre-audit evidence instead of guessing.
  • A crisp, high-contrast cluster — a visible indicator that also clears the contrast floor. The stop is recorded as a pass.

What the diff cannot decide on its own is meaningfulness: a giant box-shadow behind the whole section technically changes pixels without helping anyone. That ambiguous middle is staged with its evidence for a human to adjudicate rather than scored automatically — the same honesty about what automation can and cannot settle that every report carries.

The dead end

Detecting Keyboard Traps Before Your Users Get Stuck (SC 2.1.2)

A focus indicator you can see is only useful if focus can also leave. WCAG 2.1 SC 2.1.2 (No Keyboard Trap) requires that focus can be moved away from any component using the keyboard alone. A modal that swallows Tab, a carousel you cannot escape, or an embedded editor whose only exit is a mouse shortcut all fail it — and they strand keyboard users at the exact moment the page was working.

Trap detection works the same way the focus evidence does: the crawler walks the page with the keyboard, and at every stop it tries to leave — Tab, Shift+Tab, Escape. If none of them moves focus off the component, the stop is recorded as a trap with the exact CSS selector and the keystrokes that reproduced it. Custom components are the usual offenders: a dropdown built from divs whose keydown handler calls preventDefault() on every key, or a modal whose close button sits outside the tab order.

Both barriers — the ring you cannot see and the stop you cannot leave — are things a mouse-only test can never surface. If the remediation is not in your team's week, our engineers can scope and fix focus order and traps for you.

The fix

How to Style Accessible Focus Rings in CSS

Do not remove the outline without replacing it. Prefer :focus-visible: the browser applies it when the user is navigating with the keyboard and skips it for pointer clicks, so mouse users keep the clean look and keyboard users keep the ring:

:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
  border-radius: 4px;
}

Three rules make a ring pass instead of merely exist:

  • Contrast — the ring needs a colour that stands off both the component and the page background (SC 1.4.11 non-text contrast, 3:1).
  • Thickness — 2–3px, so the ring survives a screenshot on a phone and a low-quality display.
  • Offset — outline-offset keeps the ring from colliding with the component's own border.

If you must touch the default outline at all, restyle it — never ship a reset like *:focus { outline: none; } without an equally broad replacement. And keep the ring in your own stylesheet: it has to exist without any third-party script drawing it for you.

Do it yourself

How to Test Focus Indicators on Any Page

Put the mouse away

Navigate with Tab, Shift+Tab, Enter and the arrow keys only, starting from the browser address bar.

Follow every Tab stop

At each stop ask one question: do I know, right now, which control will activate?

Classify each stop

Call it VISIBLE, WEAK or NONE against the three definitions above.

Try to leave every stop

Open each menu, modal and carousel and tab out of it. A stop that Tab, Shift+Tab and Escape cannot leave is a keyboard trap.

Fix and re-check

Style :focus-visible with a high-contrast ring, then repeat the keyboard pass and confirm every stop shows it.

See it for yourself

Your keyboard focus, pixel-diffed and proven

Scan a page free: every Tab stop screenshotted focused and unfocused, classified as VISIBLE / WEAK / NONE, with keyboard-trap detection and the CSS to fix what fails. Conformance findings you can hand straight to a developer — no overlay widget, no quick-fix script.

Run a visual focus check

Frequently Asked Questions

What is a keyboard focus indicator?

The visual marker — usually an outline or highlight — that shows which control will activate when a keyboard user presses Enter. SC 2.4.7 (Focus Visible) requires it to be visible whenever a control has focus, and it is the primary way keyboard users keep their place in a page.

Why does outline: none fail WCAG 2.1?

Not the property itself but the missing replacement. Removing the default outline is a conformance finding when no equally visible indicator takes its place, because a sighted keyboard user can no longer tell where focus is (SC 2.4.7). If the default ring clashes with your design, restyle it — do not delete it.

How does a pixel-diff classify a focus state?

The engine screenshots each control focused and unfocused and counts the pixels that changed. Identical images mean NONE, a faint change is staged for human review as WEAK with the evidence attached, and a high-contrast change is VISIBLE. The evidence images ship with the finding, so a human auditor verifies rather than re-measures.

Can an overlay widget fix focus indicators for me?

No. An overlay draws its own outlines on top of your page at runtime; the underlying stylesheet still removes the real one, assistive technology still sees the same markup, and the moment the overlay is switched off the barrier is back. The ring has to be in your own CSS — which is why a scanner that reports the underlying defect produces findings a developer can actually fix.