Skip to main content
WCAGrules
Quick navigation

On Focus

Landing focus on something must never change the context on its own. Tabbing onto a control cannot open a window, submit a form, or throw focus somewhere else. Context is a defined thing here, and it is narrower than it sounds. Four changes count. A new user agent, a new viewport, a move of focus, and a change of content big enough to change what the page means. Everything else is allowed, so a tooltip appearing on focus is fine and a submenu opening on focus is fine. Unlike its sibling rule on input, this one has no escape. Warning the user in advance does not make a context change on focus acceptable.

Why it matters

Tab is a walk-through key. To reach the control they want, a keyboard user has to pass through every control in front of it, so anything that fires on the way past fires by accident. Turn passing through into acting and exploring the page becomes a minefield. That is not a polish problem. It is the thing that has to be true before keyboard navigation can exist at all. And focus is not only a keyboard idea, because clicking into a text field focuses it too, so a mouse user can trip the same wire.

Who this rule protects

Keyboard and screen reader users pass through every control on the way to any control, so a page that acts on focus touches almost everything they try to do. People with motor impairments are hit twice, since a tremor or a switch makes an unintended focus more likely in the first place. Users with cognitive disabilities lose their place when a page moves on its own instead of waiting to be asked.

How to check it yourself

  1. Tab across every interactive element on the page and press nothing else. Not Enter, not Space, not an arrow key.
  2. Watch for the four things that count as a context change. A new window or tab, a changed viewport, focus jumping somewhere you did not send it, or the page rearranging enough that it reads as somewhere new.
  3. Click into text fields with a mouse as well. Focus arrives that way too, and the rule covers any component receiving focus however it arrives.
  4. Leave the benign changes alone. A tooltip, a highlighted row or a submenu opening on focus changes content without changing context, and the criterion is met automatically when that is all that happens.
  5. Check whether anything loses focus the moment it gets it. Tab to it, then look at where focus actually sits, because a scripted blur sends it back to the top of the document and takes keyboard access with it.

Failures we see most often

  • A help dialog opens whenever a field receives focus and pulls focus into itself, so a keyboard user tabbing past that field is caught by it every single time.
  • A jump menu navigates to a new page the moment an option receives focus from the arrow keys, before the user has confirmed anything.
  • A form submits itself as soon as focus lands in its last field, so moving away to reread the instructions sends it.
  • A script calls blur on an element the instant it receives focus, usually to hide the focus ring. That removes the outline, removes the focus, and leaves the control operable by mouse only.
  • A single-page app routes to a new view on focus. Nothing reloads and nothing announces it, and to the user it looks exactly like landing on a different page.

Who this one is for

Read from this rule's own note above, so the grouping and the note cannot disagree.

How to fix it

  • Trigger changes on activation, never on focus. Enter, Space and click are activation. Arriving is not.
  • Let a select be arrowed through freely and act only when the user confirms. Escaping or tabbing out of it should leave the page exactly where it was.
  • Where a widget has to open something, open it on the press that asked for it, and leave focus where the user put it unless they asked to be moved.
  • Never script focus away from an element that just received it. If the focus ring is the problem, restyle the ring, because a visible focus indicator is its own requirement and both can be satisfied at once.
Step-by-step fix guides (2)

Passes vs. fails

A general illustration of the pattern rather than a test of 3.2.1. Passes: reachable, visible, activatable. Fails: a div the keyboard cannot reach.

Passes

Arrowing through the currency selector reads out the options and nothing more. Enter applies the choice, and tabbing out of it changes nothing at all.

Fails

Tabbing through the currency selector redirects the whole storefront to the EUR site the moment the first option is reached, before the shopper has chosen anything.

In audits and lawsuits

We run a focus-only pass over every audited page, tabbing through and pressing nothing else, because that is the only way to separate what focus does from what activation does. Findings cluster in two places. Legacy select menus that act on the arrow keys, and helpful widgets that open the moment they are reached. There is a third worth naming because it is cheap and it is everywhere, which is a script that removes focus the instant an element receives it, usually to hide an outline a designer disliked. That one fails four criteria at once. No automated rule exists for this criterion, so a scan finds none of it.

Go somewhere useful

Find tools, resources and your workspace.

29 destinations