How accessible is your website?Start free check
WCAG 3.2.1Level AUnderstandable

On Focus: No Surprises When Elements Get Focus

Also called: Focus change of context, Predictable focus, Change on focus

Definition

On Focus is WCAG success criterion 3.2.1. When any user interface component receives focus, it must not initiate a change of context – such as submitting a form, opening a new window or moving focus elsewhere.

On Focus is the WCAG rule that simply moving to an element must never trigger a big change. When someone presses Tab and lands on a link, a field or a button, nothing should open, submit or jump away – only activating the element may do that. It keeps pages predictable for everyone who navigates with the keyboard or a screen reader.

What it means

WCAG 3.2.1 On Focus is a Level A criterion of WCAG 2.2. Its text is short: "When any user interface component receives focus, it does not initiate a change of context."

A change of context is a major change that can disorient people who cannot see the whole page at once. W3C names four kinds: a change of user agent, of viewport, of focus, or of content that changes the meaning of the page. Showing a little extra content is not a change of context on its own.

What happens when an element gets focus Allowed under 3.2.1?
A tooltip or hint appears next to the field Yes – content change only
The element gets a visible focus outline Yes
The form is submitted No
A new window or pop-up opens No
Focus is moved to another element No
The browser navigates to another page No

People affected most are keyboard navigation users, who have to pass every element on the way to their target, and screen reader users, who may not notice that the page changed under them. People with cognitive disabilities also lose orientation when a page reacts in unexpected ways.

Focus can arrive by keyboard or by mouse click. Hovering with the mouse does not move focus unless a script makes it do so – content that appears on hover is covered by content on hover or focus instead.

Examples

Example
<!-- Bad: tabbing onto the field opens a new window -->
<input type="text" id="coupon" onfocus="window.open('/coupon-help')">

<!-- Bad: focus is pushed away as soon as it arrives (failure F55) -->
<a href="/terms" onfocus="this.blur()">Terms</a>

<!-- Good: the help opens only when the user asks for it -->
<label for="coupon2">Coupon code</label>
<input type="text" id="coupon2" aria-describedby="coupon-hint">
<p id="coupon-hint">You find the code in your welcome email.</p>
<button type="button" id="coupon-help">Coupon help</button>

W3C also lists a failing pattern from real sites: a help dialog that opens whenever a field receives focus and pulls focus away each time the user tabs past it. The user never gets beyond that field.

Do

Trigger navigation, submission and pop-ups only on click, Enter or Space. Let menus show their options while the user moves through them, and navigate only when a choice is activated. Keep a visible focus outline on every element.

Don't

Submit a form, open a window or start a redirect in an onfocus handler. Never call blur() or move focus to another element just because focus arrived. Don't auto-open dialogs when a field is reached.

How to check On Focus

    Questions

    What is a change of context in WCAG?

    A change of context is a major change of the user agent, the viewport, the focus or the meaning of the page – for example opening a new window, loading another page or moving focus. Small content changes, such as showing a hint, are not a change of context.

    Can a dropdown menu open on focus?

    Yes. Showing the options of a menu is a change of content, not of context. W3C's passing example is a menu where users move through the options with the keyboard and only activating a choice loads a new page.

    What is the difference between On Focus and On Input?

    On Focus (3.2.1) covers the moment an element receives focus. On Input (3.2.2) covers the moment the user changes a setting, such as choosing an option in a select list or ticking a checkbox.

    Is it allowed to move focus automatically?

    Not as a reaction to focus arriving. Moving focus after the user activates something – for example into a dialog they opened – is expected and fine. Moving focus away the moment an element is reached fails On Focus and, according to W3C, also keyboard and focus visibility rules.

    • On Input: Form Controls Without Surprises

      On Input is WCAG success criterion 3.2.2. Changing the setting of a user interface component – typing in a field, choosing an option, ticking a checkbox – must not automatically cause a change of context unless the user has been advised of the behavior before using the component.

      Read definition: On Input: Form Controls Without Surprises
    • Focus Order: Logical Tab Order Explained (WCAG 2.4.3)

      Focus order is the sequence in which interactive elements receive keyboard focus when a user presses Tab. WCAG 2.4.3 requires that this sequence preserves the meaning and operability of the page.

      Read definition: Focus Order: Logical Tab Order Explained (WCAG 2.4.3)
    • Keyboard Navigation: WCAG 2.1.1 Explained

      Keyboard navigation means that every function of a website can be reached and operated with a keyboard alone – usually with Tab, Shift+Tab, Enter, Space and the arrow keys. WCAG 2.1.1 requires it at Level A.

      Read definition: Keyboard Navigation: WCAG 2.1.1 Explained
    • Content on Hover or Focus: Tooltips Done Right

      Content on hover or focus is WCAG success criterion 1.4.13. Where pointer hover or keyboard focus makes extra content appear – a custom tooltip, sub-menu or pop-up – it must be dismissible without moving the pointer or focus, hoverable, and persistent until the user is done.

      Read definition: Content on Hover or Focus: Tooltips Done Right

    Let AI Handle Website Accessibility

    Built in Europe. Set up in 2 minutes, no developer needed. Put website accessibility on autopilot with AI-powered fixes and automated monitoring.

    1. 1Choose your plan
    2. 2Install in 2 min
    3. 3AI fixes your website
    4. Done