Be Mindful Of The Reading Order
When we work with content for the web, we usually don't worry about the reading flow of a document, based on writing mode and writing direction. In Latin languages, we're used to right to left, to bottom. On the web, this also means that the content will be displayed in the order it appears in the DOM. This is how most assitive technology also works. For example: screen readers will "speak" the content in document order. However when we work with Flexbox and Grid layouts, we can change the order of part or parts of the document without changing the order they appear in the document. This may have accessibility implications and may cause the accessible document and the document we open in the browser may not be the same. There are two properties that allow developers to control the flow of the page content: `reading-flow` and `order`. [reading-flow](https://drafts.csswg.org/css-display-4/#reading-flow)controls the order in which elements in a flex or grid layout are rendered to speech or are navigated to when using (linear) sequential navigation methods. The possible values of the property are: normal : Follow the order of elements in the DOM. flex-visual : Only takes effect on flex containers. Follows the visual reading order of flex items, taking the writing mode into account. flex-flow : Only takes effect on flex containers. Follows the flex-flow direction. grid-rows : Only takes effect on grid containers. Follows the visual order of grid items by row, taking the writing mode into account. grid-columns : Only takes effect on grid containers. Follows the visual order of grid items by column, taking the writing mode into account. grid-order : Follows the order-modified document order. Therefore, as normal unless the order property has been used to change the order of items. I find this property problematic. Reading this nore in the specification for `reading-flow`: > The source document should express the underlying logical order of elements. The reading-flow property exists for cases where a given document can have multiple reading orders depending on layout changes, e.g. in response to media queries. In such cases, the most common or most fundamental reading order should be encoded in the source order so that the document is sensical without CSS. > > Source Note on [Reading Order: the reading-flow property](https://drafts.csswg.org/css-display-4/#reading-flow) I'm trying to understand the accessibility note. Does changing the layout of a page actually change the meaning of the text being read? In reading the explanation of this example in it took me a while to understand it. Given this HTML: ```html ``` Using the folllowing CSS: ```css .wrapper { display: flex; flex-direction: row-reverse; } ``` keyboard navigation using the [[tab]] key will navigate in the same flex direction, for English, this would be right to left (`Blog`, `About`, `Main`). If we now add the `reading-flow: flex-visual` to the block the content will now read like expected, left to right (`Main`, `About`, `Blog`). ```css .wrapper { display: flex; flex-direction: row-reverse; reading-flow: flex-visual; } ``` When using `reading-flow` make sure that changing the visual reading flow doesn't change the meaning of the content. [order](https://drafts.csswg.org/css-display-4/#order-property) controls the order in which flex items or grid items appear within their container, by assigning them to ordinal groups. Given the following HTML: ```html
Card Title
Card Content