[css-display][css-pseudo] Interaction of display:contents and ::first-line (original) (raw)

Typically, inheritance follows the element tree. However, the ::first-line is able to "hijack" the inheritance of some properties:

During CSS inheritance, the portion of a child element that occurs on the first line only inherits properties applicable to the ::first-line pseudo-element from the ::first-line pseudo-element.

The problem is that the place in which ::first-line is generated depends on the box tree, and display: contents generates no boxes, so I'm not sure how they interact.

The implementations of display: contents (Firefox and Chrome) are not interoperable, and both seem undesirable:

For example, https://jsfiddle.net/0q8paowL/

main::first-line { color: blue; text-decoration: underline; } div { display: contents; color: green; letter-spacing: 10px; } span { display: contents; color: red; }

aaa bbb

ccc

I will attempt to represent the inheritance using a fictional tag sequence, which I'm not sure is right because ::first-line only exists in the box tree and display: contents in the element tree.

I see three reasonable possibilities: