display: contents has this note
As only the box tree is affected, any semantics based on the document tree, such as selector-matching and event handling, are not affected.
This is kinda obvious: if display: contents can be set to an element via selector-matching, it shouldn't affect selector-matching. And event handling is entirely a DOM thingie.
CSS Cascade says inheritance follows the document tree but that's a blatant lie, e.g. ::first-line intercepts inheritance for some properties, and it is based on the box tree. Therefore, I don't think it's obvious at all that children elements of a display: contents still inherit from it.
So please note style inheritance is not affected by display: contents neither.
display: contentshas this noteThis is kinda obvious: if
display: contentscan be set to an element via selector-matching, it shouldn't affect selector-matching. And event handling is entirely a DOM thingie.CSS Cascade says inheritance follows the document tree but that's a blatant lie, e.g.
::first-lineintercepts inheritance for some properties, and it is based on the box tree. Therefore, I don't think it's obvious at all that children elements of adisplay: contentsstill inherit from it.So please note style inheritance is not affected by
display: contentsneither.