CSS Reading Flow: Logical Order for Grid and Flex Layouts

reading-flow: keyboard order that follows a grid or flex layout

Grid and flexbox make it easy to place items visually in a different order than in the HTML: order, grid-area, flex-direction: row-reverse, dense packing. Keyboard and screen reader users still move through the HTML order, so the focus jumps around the screen. The CSS property reading-flow tells the browser to follow the visual layout for focus navigation and reading order in a grid or flex container.

Problem: A theme’s feature section is a grid where the “Get started” card is placed first visually with grid-area, but comes last in the HTML for SEO reasons. Tabbing through the section jumps from the bottom card to the top one and back, which fails WCAG’s focus order criterion.

Solution: Prefer fixing the HTML order where possible. Where the visual order must differ, set reading-flow: grid-rows (or flex-visual for flex containers) on the container so that Tab follows the visual rows, and check the result with the keyboard in a supporting browser.

A grid with a reordered item

.ha-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-areas:
        "start start start"
        "a     b     c";
    reading-flow: grid-rows;
}

.ha-features__start { grid-area: start; }
<section class="ha-features">
    <a class="ha-card" href="/feature-a/">Feature A</a>
    <a class="ha-card" href="/feature-b/">Feature B</a>
    <a class="ha-card" href="/feature-c/">Feature C</a>
    <a class="ha-card ha-features__start" href="/start/">Get started</a>
</section>

Visually, “Get started” is the first row. With reading-flow: grid-rows, Tab goes to “Get started” first, then A, B, C, row by row, as a sighted keyboard user expects. Screen readers that follow the accessibility tree get the same order.

The values

  • normal: the DOM order, as before.
  • flex-visual: for flex containers, the visual order including order and reversed directions, following the writing mode.
  • flex-flow: the flex flow direction, regardless of the writing mode.
  • grid-rows, grid-columns, grid-order: for grid containers, by visual rows, by visual columns, or by the order property only.
  • source-order: lets reading-order on items take effect in other layouts.

The property applies to the direct children of the container. Elements outside the container keep the document order.

reading-order for single items

.ha-promo { reading-flow: source-order; }
.ha-promo__cta { reading-order: -1; }   /* this item first in reading order */

reading-order on an item sets its position within a container that has reading-flow, similar to order but for reading instead of layout.

Fix the HTML first

reading-flow is a repair tool. The most robust solution remains a source order that makes sense, with CSS only arranging it: the order of content in the HTML is what search engines, readers without CSS and older assistive technology see. In a block theme, the order of blocks in the editor is the HTML order, so rearranging the blocks is usually the better fix than CSS reordering. Grid layout basics: CSS grid layout fundamentals.

NOTE: reading-flow shipped in Chrome and Edge 137 (May 2025). Check current support in other browsers; without support, the DOM order applies, which is the current behavior, so adding the property does no harm. Logical properties, which keep layouts correct in right-to-left languages, are the related tool for writing direction: CSS logical properties.