whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.03k stars 2.63k forks source link

'reading-flow' and "display: contents" #10643

Closed tabatkins closed 10 hours ago

tabatkins commented 1 day ago

What is the issue with the HTML Standard?

Currently, the reading-flow PR specifies that if a reading flow item is display:contents, then two things happen:

  1. The item itself is treated as "not participating", so it gets put at the end of the reading order, arranged in DOM order with other non-participating things.
  2. The item is treated as a reading flow container itself, so its children follow it to the end of the order, and are arranged in the visual order specified by the parent reading flow container.

There was significant discussion on this behavior in the joint CSS/WHATWG meeting at TPAC about making this work better in several cases. Notably, it was considered bad if adding a "useless" 'reading-flow' value (applied to an element where DOM order and visual order are already consistent) could cause the reading order to now mismatch the visual order, because some of the items are in a display:contents subtree. For example, this markup:

<div class=flex>
  <button class=item>A</button>
  <div class="item container">
    <button class=item>B1</button>
    <button class=item>B2</button>
  </div>
  <button class=item>C</button>
</div>
<style>
.flex { display: flex; }
.container { display: contents; }
</style>

Currently, has consistent DOM, visual, and tabbing order: A, B1, B2, C. But if we added .flex { reading-order: flex-flow; }, the tabbing order would change to A, C, B1, B2, despite the DOM order already matching the "flex-flow" order!

Conclusions reached during the meeting:

dizhang168 commented 21 hours ago

Thanks for summarizing. Note there is an existing issue on this topic: https://github.com/whatwg/html/issues/10533

Maybe we can put this as a comment on that issue and close this to avoid duplication?

tabatkins commented 10 hours ago

Comment copied over, this issue can be closed.