Closed
Description
CSS Display says
anonymous boxes (which only exist in the box tree) inherit through their box tree parentage
I think this implies an anonymous box doesn't inherit from its parent element if the parent has display: contents
, because that means
The element itself does not generate any boxes
For example,
<section>
<div>Foo</div>
</section>
section {
color: red;
}
div {
color: green;
display: contents;
}
Foo is wrapped inside an anonymous inline box, so according to the quote above, it should inherit the red color from its parent box, which is the box of the section, because the div does not generate boxes.
But this seems wrong, because if we had
<section>
<div><span>Foo</span></div>
</section>
then the span would inherit the green color from the div through the element tree.
In Firefox and Chromium the text in the first example is green as expected, I think it's just that the spec is confusing.