Skip to content

Editorial review: Add reading-flow and reading-order docs #39404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
May 29, 2025

Conversation

chrisdavidmills
Copy link
Contributor

Description

Completing work originally started by @Praveen7294 in #38859, on documenting the reading-flow and reading-order properties.

See https://drafts.csswg.org/css-display-4/#reading-flow for the specification.

This PR adds ref pages for the two properties, but also updates the CSS Display module page to suit, and adds a glossary entry for "reading order".

Motivation

Additional details

Related issues and pull requests

Praveen7294 and others added 20 commits March 30, 2025 06:05
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@chrisdavidmills chrisdavidmills requested review from a team as code owners May 5, 2025 10:33
@chrisdavidmills chrisdavidmills requested review from bsmth and removed request for a team May 5, 2025 10:33
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:Glossary Glossary entries size/m [PR only] 51-500 LoC changed labels May 5, 2025
@chrisdavidmills chrisdavidmills changed the title Praveen7294 add reading flow docs Add reading-flow and reading-order docs May 5, 2025
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed property pages


The `reading-order` property lets the author change where in the reading order an element is read out or tabbed to. It enables authors to override the reading order set by the [reading-flow](/en-US/docs/Web/CSS/reading-flow) property on its parent.

The default `reading-order` value is `0` for elements inside a block, flex, or grid container. This puts them all in the same ordinal group. Sibling elements are ordered starting from the lowest numbered ordinal group to the highest. Therefore, to cause an element to be read out after its siblings, you could set a `reading-order` value or `1` or more on it. To cause an element to be read out before its siblings, you could set a `reading-order` value or `-1` or less on it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default `reading-order` value is `0` for elements inside a block, flex, or grid container. This puts them all in the same ordinal group. Sibling elements are ordered starting from the lowest numbered ordinal group to the highest. Therefore, to cause an element to be read out after its siblings, you could set a `reading-order` value or `1` or more on it. To cause an element to be read out before its siblings, you could set a `reading-order` value or `-1` or less on it.
For reading and navigation, elements inside a block, flex, or grid container in a container are sorted by ascending `reading-order` value and then by their source code order. Items not given an explicit `reading-order` value are assigned the default value of `0`. This puts them all in the same ordinal group by default.
Sibling elements are ordered starting from the lowest numbered ordinal group to the highest. Therefore, to cause an element to be read out after its siblings, you could set a `reading-order` value or `1` or more on it. To cause an element to be read out before its siblings, you could set a `reading-order` value or `-1` or less on it.
The `reading-order` defines the reading and tabbing order. This property has no effect on visual order. To alter the visual order of items in a container, see the {{cssxref("order")}} property.

how does this interact with tabindex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

As for tabindex, that is a good question — I've tried a bit of experimentation, but found the results a little bit confusing.

@rachelandrew, can you give us a summary of how reading-flow/reading-order interact with tabindex?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading flow containers become focus scope owners. The PR here contains the HTML definition.

I believe this explainer is also correct, but I'd treat that PR as the source of truth,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ... quite complicated. I've done a bit of testing, and from my findings, it looks like the effects of tabindex are pretty much ignored when reading-flow/reading-order are set, and their effects override them. When you set tabindex="0" on a load of items and place them inside a reading flow container, they follow the reading flow set by reading-flow/reading-order. When you try using positive tabindex values, they are basically ignored.

Do you think this is accurate?

I wonder whether it would be good to mention something like this on both pages, say that a bunch of stuff that used to be hacked around using tabindex can now be fixed using reading-flow/reading-order, and follow it up with another reminder not to use positive tabindex values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so from reviewing @estelle's tests, it looks like I am right. I'm not convinced we need to add another demo to demonstrate that reading-flow/reading-order overrides tabindex and it is ignored while they are in effect. We should just add some explanation to each page to mention this.

Does that work for you, @rachelandrew, or have I got this wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct, it essentially overrides tabindex, as if people were using positive values they probably shouldn't be in most cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool; I've added a subsection to the "Description" section on both property pages, in my next PR.

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner May 15, 2025 17:51
@chrisdavidmills chrisdavidmills requested review from estelle and removed request for a team May 15, 2025 17:51
@github-actions github-actions bot added the Content:HTML Hypertext Markup Language docs label May 15, 2025
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A second pass. After this I think we will be close if not fully there.

@chrisdavidmills chrisdavidmills requested a review from estelle May 20, 2025 11:22
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to review reading-order

@estelle
Copy link
Member

estelle commented May 22, 2025

I am having issues with the reading-order specification versus the implementation. I am able to get reading-order to impact the reading order of non-block level elements of block reading flow containers (have other than normal set). I am also able to get reading-order to work on block-level children of containers that are not themselves reading flow containers (the parent defaulting to normal).

@estelle
Copy link
Member

estelle commented May 22, 2025

Inline elements supporting reading-order example: https://codepen.io/estelle/pen/zxGOvLB

@estelle
Copy link
Member

estelle commented May 23, 2025

I had a few instances where reading-order worked with reading-flow: normal, but now I can't seem to replicate it, so thinking the JS may have been setting the reading-order: source-order and I didn't catch it.

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there may be a bug in the spec or in the implementation, but i went ahead and reviewed it

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops. Started reviewing before the tabindex info was added to the property pages. So, submitting the few tweaks, and will revisit when you let me know to revisit.

Comment on lines 17 to 20
- Reading flow
- : A modified reading order.
- Reading flow container
- : An element with a reading flow set on it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if you want me to create the other glossary page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with you on this point, but you seem pretty determined about this. Do you think you can do it as a separate PR after this one has been merged, so as not to hold it up?

Copy link
Collaborator

@wbamberg wbamberg May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "reading flow" here the thing that in the spec is called "rendering-defined sibling reading flow" (https://drafts.csswg.org/css-display-4/#rendering-defined-sibling-reading-flow)? Because if so, these definitions seem to be backwards. The spec defines "rendering-defined sibling reading flow" in terms of "reading flow container", but this reverses that, defining "reading flow container" in terms of "reading flow".

Which is a problem, because the only solid (i.e. spec-derived) definition of "reading flow" is in terms of "reading flow container", so you have a circularity.

FWIW I don't think this needs a separate glossary entry, but as it stands, in this glossary entry, it's unclear that these are formal CSS terms, as it goes straight from general prose into this DL, without any context. I think it needs a heading like "Setting reading order in CSS" before it starts talking about the CSS properties, and then a line to introduce these definitions so I know what I'm staring at.

And if we're going to include these as official CSS spec terms, we should be precise about them.

(I think the scroll snap comparison is instructive, and I have the same issues with contextualization there).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @wbamberg. I've read the spec again, and you are right — I did have the definitions the opposite way round. I've modified the definitions so that "reading flow container" is defined first, and "reading flow" is defined in terms of it.

I've also added a heading and a sentence to introduce the terms so that it flows better.

I'm not exactly sure about including the official spec terms in both cases; I mean, the official spec term for reading flow is "rendering-defined sibling reading flow", but I thought that was a bit wordy and unhelpful for the MDN audience, so I chose "reading-flow" ;-)

But yes, I appreciate the need for precision in such a case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!

@wbamberg wbamberg merged commit 7dda25d into mdn:main May 29, 2025
8 checks passed
@chrisdavidmills chrisdavidmills deleted the Praveen7294-add-reading-flow-docs branch May 30, 2025 06:26
@chrisdavidmills
Copy link
Contributor Author

@estelle @wbamberg super, cheers folks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:Glossary Glossary entries Content:HTML Hypertext Markup Language docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants