Keyboard focus must be visible

Every element that receives keyboard focus must show it, with an outline, border, underline or colour change. Without a visible indicator, keyboard users cannot tell where they are on the page.

Readabler check

Rule IDrdb-focus-visible
ImpactSerious
Success criterion 2.4.7 Focus Visible · AA
StandardsWCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549
Readabler fix Fixed automatically

Example

Before
<style>
  a:focus, button:focus { outline: none; }
</style>
<a href="/basket">Basket (2)</a>
<button type="button">Checkout</button>

Pressing Tab moves focus, but nothing on screen changes. The user cannot tell what Enter will activate.

After
<style>
  a:focus-visible, button:focus-visible { outline: 3px solid #1a5fb4; outline-offset: 2px; }
</style>
<a href="/basket">Basket (2)</a>
<button type="button">Checkout</button>

Each Tab press draws a blue outline around the focused link or button.

Why it matters

For people who navigate with a keyboard, the focus indicator plays the role of the mouse pointer. It shows which link Enter will follow and which field will receive typing. Without it, they have to guess, and a wrong guess can submit a form or delete an item.

This affects sighted keyboard users with motor disabilities, tremor or repetitive strain injury, switch users, people who use voice control to send key presses, and power users who simply prefer the keyboard. People with attention or memory difficulties lose their place even more easily.

The most common cause is a CSS reset or a design decision that removes the browser outline (outline: none) because it looked odd on mouse click, without a replacement. Visible focus is required by WCAG 2.4.7 at Level AA.

How to fix it

Do not remove the outline without a replacement. Search your CSS for outline: none, outline: 0 and frameworks' focus resets.

Use :focus-visible. Browsers apply it on keyboard focus but usually not on mouse click, which removes the reason to hide focus at all:

<style>
  :focus-visible {
    outline: 3px solid #1a5fb4;
    outline-offset: 2px;
  }
</style>

Make it easy to see. Use a thick outline or a clear change, with at least 3:1 contrast against the colours next to it. A small colour shift on the text is easy to miss.

Dark and coloured backgrounds. A single colour may vanish on some sections. A double ring works on any background:

<style>
  :focus-visible { outline: 2px solid #fff; box-shadow: 0 0 0 4px #111; }
</style>

Custom components that put focus on a hidden input (custom checkboxes, toggles) need the style on the visible part, for example with :focus-within or a sibling selector such as input:focus-visible + .toggle.

Checklist

  1. Remove outline: none rules that have no replacement.
  2. Style :focus-visible for every interactive element.
  3. Give the indicator at least 3:1 contrast.
  4. Show focus on the visible part of custom controls.

How the check works

The check presses Tab through the page in a real browser, up to 150 times. Before that, it records how each focusable element looks: outline, box shadow, border, background, text colour, underline, opacity, transform and filter, for the element, its ::before and ::after, its first child and three ancestors. After each press, and after focus transitions of up to 300 ms, it compares. If nothing changed, the element is reported. A change too faint to notice still passes: check contrast by eye.

Resources

Updated October 27, 2026