- Level
- A
- Since
- WCAG 2.0
- Entries
- 99 / 193
2.4.3 Focus Order
When someone moves through a page with the Tab key, focus must travel in an order that matches the meaning and layout of the page.
/ What it requires
Keyboard users move from one control to the next in sequence, and that sequence is all they have. If it jumps from the header to the footer and back, or stays outside a dialog that has just opened, the page stops making sense. Screen reader users cannot see the layout that would explain the jump. Sighted keyboard users, and people using magnification who see only a small part of the screen, lose track of where the focus went.
The criterion applies where a page can be navigated sequentially and the sequence affects meaning or operation. The order does not have to match the visual order exactly. It has to preserve meaning and operability, and there can be more than one valid order. What fails is an order that separates related controls, sends the user through the page out of sequence, or leaves focus behind the dialog or menu that has just opened on top of the page.
/ How pages fail it
- Positive tabindex values such as tabindex="5" pull some controls to the front of the order, ahead of everything else.
- The CSS order property, flex-direction: row-reverse or absolute positioning shows controls in one sequence while the DOM lists them in another.
- A modal dialog opens but focus stays on the page behind it, so Tab keeps moving through content the user cannot see.
- A dialog or menu closes and focus drops to the top of the document instead of returning to the button that opened it.
- Content inserted by script, such as an expanded panel, is appended to the end of the DOM, far from the control that revealed it.
/ How to check it yourself
- Press Tab from the top of the page to the bottom and watch the focus indicator. It should move the way you would read the page, without doubling back.
- Press Shift+Tab back up and check that the reverse path mirrors the forward one.
- Open each dialog, menu and expandable panel with the keyboard. Focus should move into the new content, stay there while a modal dialog is open, and return to the opener when it closes.
- Search the markup for tabindex values above 0. In the DevTools console, document.querySelectorAll('[tabindex]') lists every element that sets one.
- Read the DOM order in the Elements panel and compare it with the visual layout.
/ How to fix it
- Remove every positive tabindex. Use tabindex="0" to add an element to the natural order and tabindex="-1" for elements that are focused only from script.
- Reorder the DOM so that it matches the visual sequence, instead of rearranging with the CSS order property or absolute positioning.
- On opening a modal dialog, move focus into it. The native dialog element opened with showModal() does this, and the inert attribute keeps focus out of the rest of the page.
- On closing a dialog or menu, call focus() on the control that opened it.
- Insert revealed content directly after its trigger in the DOM.
/ What our scanner checks
dialog-focus-outside reports a dialog that is open when the page is checked while focus sits outside it. focus-order-jumps compares the position of each tab stop with the previous one and reports focus moving back up the page without moving right, ignoring pinned elements. Three overlapping rules report tabindex values above 0. No check can tell whether an order makes sense, and none opens a closed dialog.
/ Who fails it, in our own measurements
One page per body, measured by automated checks on a weekly schedule. Any body that has fixed something since the last sweep will show it at the next one, and every entity page carries a right of reply.
/ Questions about this criterion
Does focus order have to match the visual order?
Not exactly. The criterion requires an order that preserves meaning and operability, and several orders can do that. In practice a layout read from the top down, in the same sequence the DOM lists it, is what users expect, and a mismatch between the DOM and the screen is the most common reason an order stops making sense.
Is a positive tabindex a WCAG failure?
Not automatically. HTML allows a positive value, and if the resulting order still preserves meaning the page passes. The trouble is that elements with positive values come before every other control on the page, so one of them is enough to reshuffle the sequence, and the order breaks whenever the page is edited. W3C documents the resulting disorder as failure F44.
Where should focus go when a dialog opens and closes?
When a modal dialog opens, focus should move into it, to the first control, the heading or the dialog itself, and Tab should stay within it while it is open. When it closes, focus should return to the control that opened it. Leaving focus on the page behind makes keyboard users tab through content they cannot see.
