Rule
Focus order vs visual order
CSS reordering should not make Tab jump against the visual order.
- Rule
visual-order-divergence- WCAG 2.2
- 2.4.3 Focus Order (opens in a new tab) (Level A)
- Severity
- Moderate
What it checks
Looks at keyboard-focusable controls that are siblings in the same flex or grid container. When the container uses flex-direction: row-reverse or column-reverse, or a child sets order, the order the controls appear in on screen, row by row, is compared with their order in the source, which is the order Tab follows. Right-to-left layouts are read from the right.
Containers that do neither are left alone, so ordinary wrapping, floats and positioning never trigger it. Controls one level deeper, such as links inside cards, are not compared.
When a person decides
When the two orders differ, the container is sent for review. A reversed row of equal choices may make perfect sense; whether the focus order still preserves meaning and operation is a person's call.
Example
Sent to review
<div style="display: flex; flex-direction: row-reverse; justify-content: flex-end">
<button type="button">Continue</button>
<button type="button">Back</button>
</div>
Passes
<div style="display: flex">
<button type="button">Back</button>
<button type="button">Continue</button>
</div>
The engine is tested against both examples.
How to fix it
Change the source order to match the visual order instead of rearranging with CSS. If the difference is harmless, record why.
Check your own pages
This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.