Accessibility Wiki

Receiving focus must not trigger a change of context

Rule on-focus-context-change · Forms · impact serious · Static + live

↩ Back to the rules index · WCAG cross-reference

Why it matters

Merely tabbing onto an element must be safe. An onfocus handler that submits or navigates means keyboard users cannot even pass over the element without being yanked somewhere else; onfocus="this.blur()" is as bad — it makes the element impossible to reach by keyboard at all. Only inline handlers are visible to static analysis.

How to fix

Trigger navigation and submission from explicit activation (click/Enter), never from focus. Remove blur-on-focus hacks; use tabindex="-1" if something must not be tabbable.

Example

✕ Fails
<input aria-label="Coupon code" onfocus="this.blur()">
✓ Passes
<input aria-label="Coupon code" onfocus="this.select()">

Example

✕ Fails
<a href="/cart" onfocus="window.location='/checkout'">Cart</a>
✓ Passes
<a href="/cart" onfocus="highlight(this)">Cart</a>

WCAG success criteria

3.2.1 On Focus — Level A

Merely receiving focus must never trigger a change of context (navigation, form submission, a new window, or moved focus).

Understanding 3.2.1

Standards

This rule contributes to the following standards:

WCAG A EN 301 549 Section 508 Trusted Tester

Standard Criteria
Section 508 3.2.1
EN 301 549 9.3.2.1

References