Skip to content

Focus order that jumps around the page

CSS reverses a row of buttons on screen while the markup keeps the old order, so Tab moves against the layout.

Broken Focus starts at the right.
Fixed Focus follows the row.
The same control broken and fixed.
01

The problem

Keyboard users watch focus move against the layout, lose their place, and can press the wrong button.

02

Try it

Press Tab and watch which way focus moves.

Tab through the three buttons. Does focus move the way the row reads, left to right?

Focus last moved: (none yet)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Reorder the markup to match the design, or drop the CSS that reverses it.

  1. 1Markup order is focus order: CSS may not reverse or reorder focusable items.
  2. 2Use only tabindex 0 or -1, never a positive number.
  3. 3Check each breakpoint, because layouts reorder at narrow widths.
Before A row reversed in CSS

html

<div class="actions">  <a href="/basket">Back to basket</a>  <button type="button">Save for later</button>  <button type="submit">Place order</button></div>

css

.actions {  display: flex;  flex-direction: row-reverse;  gap: 12px;}
After

Markup that follows the design

html

<div class="actions">  <button type="submit">Place order</button>  <button type="button">Save for later</button>  <a href="/basket">Back to basket</a></div>

css

.actions {  display: flex;  justify-content: flex-end;  gap: 12px;}

04

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after layout or component styles change.

Limits

This is a starting pattern, not a guarantee for every application. It covers a static row of actions. Data grids, carousels and widgets that move focus with arrow keys follow their own patterns and need their own checks. Whether an order preserves meaning is a judgement about the content, so test the complete journey on your real pages.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work