Check 11.11 · Semantic HTML and accessibility

Check DOM reading order

Check that the order of the HTML follows the visual and logical order of the page; fix order, flex-direction, grid and tabindex in the CSS, CMS or framework.

Priority
Important
Difficulty
Intermediate
Estimated time
1 to 4 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

The reading order of a page is the order of its elements in the DOM (Document Object Model), not their position on screen. It is the order in which screen readers read, the Tab key moves and bots extract text. The task is to check that this order is logical (heading, introduction, content, then secondary elements) and that it matches what you see. Once it is done, a page displayed without CSS still makes sense from top to bottom.

Why it matters

Modern CSS can move blocks around visually without touching the HTML: the order property, flex-direction: row-reverse or column-reverse, explicit placement in a grid, position: absolute. The page looks right, but a screen reader reads the price before the product name, or the Tab key jumps from the menu to the footer before coming back to the content. WCAG success criteria 1.3.2 “Meaningful Sequence” and 2.4.3 “Focus Order” forbid this when the order changes the meaning or the operation.

Bots also read the code in order. Google indexes the text of the rendered HTML; the crawlers of generative engines, which often do not execute JavaScript, extract the text of the source HTML in the order it arrives, then split it into passages. An answer block placed at the end of the code and moved up with CSS, or an introduction separated from its heading by three promotional blocks, produces less coherent passages. No search engine documents a penalty tied to DOM order: the expected effect is cleaner extraction, not a ranking signal.

What it improves

  • Accessibility Consistent reading and keyboard navigation for users of screen readers, magnifiers and keyboards.
  • Extraction by generative engines Heading, answer and details stay grouped in the code, which makes it easier to build quotable passages. A plausible effect, not publicly measured.
  • Robustness The page stays readable if the CSS does not load, in the browser's reader mode or in a link preview.
  • Rankings No documented direct effect.

How to check

Turn off the CSS. In WAVE, turn off the Styles option in the sidebar: the page is displayed linearized, in code order. In Firefox, use the View > Page Style > No Style menu. Read from top to bottom: the order must make sense.

Visualize the code order. In Chrome, Elements panel, Accessibility tab, “Source Order Viewer” section, check “Show source order”: DevTools numbers the child elements of the selected element in code order. A number 4 shown at the top left reveals an element moved by CSS.

Move through with the keyboard. Press Tab from the top of the page: focus must move from left to right and from top to bottom in languages read in that direction, without jumps. In Firefox, the Accessibility Inspector offers a “Show Tabbing Order” option that numbers the focusable elements on the page.

Look for the causes in the CSS.

grep -rn -E "order:\s*-?[0-9]|row-reverse|column-reverse|grid-(row|column|area):|grid-template-areas" --include=*.css --include=*.scss .
grep -rn -E 'tabindex="[1-9]' --include=*.{html,php,twig,liquid,tsx,jsx,vue,blade.php} .

Not every result is an error: just check that the resulting visual order matches the code order, at every responsive breakpoint.

Compare with what a bot reads. Fetch the source HTML and read its text in order:

curl -s https://example.com/page | sed -e 's/<[^>]*>/ /g' | tr -s ' \n' | head -c 3000

The main heading and the first useful paragraph must appear early, before secondary blocks.

How to implement

Before you start

Target code order for a content page:

  1. “Skip to content” link, header, main navigation;
  2. <main>: breadcrumb, H1, introduction or short answer, content, calls to action related to the content;
  3. complementary content (<aside>): related articles, callouts;
  4. footer.

For a product page: name (H1), price and availability, buy button, then description, specifications and reviews. For a page with columns, the code follows the order in which a person would read the screen.

Three rules:

  • Write the HTML in logical order, then position with CSS. Not the other way around.
  • Only use order, *-reverse and grid placement if the resulting visual order stays that of the code, or for elements whose order does not matter (decorative thumbnails).
  • Never use a positive tabindex. tabindex="0" makes an element focusable at its place in the code; tabindex="-1" makes it focusable by script only; a positive value creates a parallel order that is impossible to maintain.

A common example: image to the right of the text on desktop, image above it on mobile. Do not move the text up with order: write the text first and position the image with the grid.

<section class="bloc">
  <div class="bloc__texte">
    <h2>24-hour delivery</h2>
    <p>Ordered before 2 pm, shipped the same day.</p>
  </div>
  <img class="bloc__image" src="/img/livraison.webp" alt="" width="640" height="420">
</section>
.bloc {
  display: grid;
  gap: 2rem;
  grid-template-areas: "image" "texte";
}

.bloc__texte { grid-area: texte; }
.bloc__image { grid-area: image; }

@media (min-width: 768px) {
  .bloc {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "texte image";
  }
}

Here the image is decorative (alt="") and moving it does not change the meaning: this is acceptable. If the image carried information, or if two blocks of text swapped places, the HTML would have to be reordered.

Good to know: the CSS reading-flow property makes the screen reader and the Tab key follow the visual order of a flex or grid container. MDN classes it as experimental, with limited support: do not rely on it, and fix the order of the HTML.

WordPress

Versions WordPress 6.4 and later (checked up to 7.1); Elementor 3.x and 4.x (Flexbox containers).

  • Block editor: the order of blocks in List View (Shift + Alt + O) is the code order. The Columns block stacks columns on mobile in code order: put the text column first if it must be read first.
  • Page builders: Elementor lets you reverse columns on tablet or mobile, and its flex containers accept a reversed direction and a custom order per element. These settings only change the display. Use them only for elements whose order hardly matters; otherwise, reorganize the structure. Divi and the other builders work the same way.
  • Themes: check in header.php or in the header template part that the navigation comes before <main>, and that sidebars come after the content in the code, even if they are displayed on the left.

Shopify

Versions Shopify theme editor, Online Store 2.0 themes, November 2026.

In the theme editor, the order of sections and blocks in the left sidebar is the code order. In the product section, place blocks in reading order: title, price, variant picker, buy button, then description. Also check the theme's stylesheets: some “image on the right” layouts use flex-direction: row-reverse. In your own CSS, prefer the grid placement from the example above.

Webflow

Versions Webflow Designer, all plans, November 2026; Wix Editor, Wix Studio and Squarespace 7.1 for the last remark.

In the Navigator, the order of elements is the code order. The flexbox “Reverse” settings and the custom order of children (First, Last, custom value) only change the display: reserve them for decorative elements and check each breakpoint. Wix and Squarespace place elements freely on the page: check the resulting reading order with WAVE (Styles turned off) and, in Wix, adjust the reading order suggested by the Accessibility Wizard if it is available for your editor.

Laravel

Versions Laravel 10 to 13, Tailwind CSS 3 and 4.

In the Blade layout, keep the logical order and let the CSS position the columns:

<body>
    <a href="#contenu" class="visually-hidden-focusable">Skip to content</a>
    @include('partials.header')

    <div class="page">
        <main id="contenu" tabindex="-1" class="page__contenu">
            @yield('content')
        </main>

        <aside class="page__barre">
            @yield('sidebar')
        </aside>
    </div>

    @include('partials.footer')
</body>
@media (min-width: 1024px) {
  .page {
    display: grid;
    grid-template-columns: 18rem 1fr;
    grid-template-areas: "barre contenu";
  }

  .page__contenu { grid-area: contenu; }
  .page__barre { grid-area: barre; }
}

The sidebar is displayed on the left but read after the content: this is intended, and it is the only move to accept here. With Tailwind, the order-first, order-last, flex-row-reverse and md:order-* classes carry the same risks as their CSS equivalents: search for them in the views.

Next.js

Versions Next.js 15 and 16 (React 19).

The order of the JSX is the order of the DOM. Two pitfalls specific to frameworks:

  • Portals (createPortal): a modal rendered at the end of the <body> ends up far from the button that opens it. Move focus into the modal when it opens and return it to the button when it closes; the <dialog> element with showModal() does this natively.
  • Content added after the fact: a banner injected at the top of the page after hydration shifts the order and the focus. Render it on the server in its place, or insert it at a point that does not precede the content.

Both remarks also apply to Nuxt, Astro and SvelteKit.

Common mistakes

  • Putting the sidebar before the content in the code because it is displayed on the left: the screen reader reads the filters and callouts before the H1.
  • flex-direction: row-reverse for an alternating layout: on a zigzag services page, every other row is read in the wrong order with the keyboard.
  • Positive tabindex values inherited from old forms: they make focus jump to the start of the page.
  • Reordering only on mobile: the mobile version, which Google uses for indexing, then has a visual order that differs from the code.
  • Trusting the visual editor: what you see in a page builder says nothing about the code order. Test the published page.
  • Mobile menu placed at the end of the <body> and opened by a button at the top: focus goes to the bottom of the page.

Frequently asked questions

Does the order of the HTML code affect SEO?

No search engine documents a ranking factor tied to DOM order. Google indexes the text of the page wherever it sits. Order matters for accessibility, since screen readers and the Tab key follow it, and for clean extraction: a bot that splits text into passages gets more coherent blocks when the heading, the answer and the details follow one another in the code.

Can the CSS order property be used without harming accessibility?

Yes, if the resulting visual order changes neither the meaning nor the keyboard path, for example to move a decorative image. It becomes a problem as soon as it swaps elements that are read or focusable: a screen reader and the Tab key always follow the code order, not the display. When in doubt, reorder the HTML and keep CSS for presentation.

How can you see the reading order of a page?

Turn off the CSS: with the Styles option of the WAVE extension or Firefox's View, Page Style, No Style menu, the page is displayed in code order. Chrome's developer tools also offer the Source Order Viewer, which numbers elements in DOM order. Complete this by moving through the page with the Tab key to check the order of interactive elements.

Should the navigation come before or after the content in the code?

Keep the usual order: header and main navigation before the content, preceded by a “Skip to content” link that jumps straight to the main element. This is the order screen reader and keyboard users expect. Sidebars and complementary content, on the other hand, go after the main content in the code, even if they are displayed on the left.

Updated on

Topic checklist (PDF)

And now?

In the “Semantic HTML and accessibility” topic

  1. Use header, main, nav, article and footer appropriately
  2. Use elements suited to the content
  3. Structure tables and lists with native elements
  4. Distinguish action buttons from navigation links
  5. Provide ALT text for informative images
  6. Use empty ALT for decorative images
  7. Check color contrast
  8. Test keyboard navigation
  9. Check form labels
  10. Use ARIA when necessary
  11. Check DOM reading order
  12. Avoid information available only on hover
  13. Provide text alternatives for media
  14. Check applicable WCAG guidelines
  15. Test with axe, WAVE or Lighthouse