-
Notifications
You must be signed in to change notification settings - Fork 756
Open
Labels
Description
Some years ago I proposed a ::contents pseudo-element. I have been refining the details in https://github.com/Loirooriol/css-contents, and yesterday someone proposed the same idea, so I decided to file this issue.
To summarize, elements generate a ::before pseudo-elements at the beginning of their contents, and an ::after one at the end. This proposal wraps the contents inside a new ::contents pseudo-element.
In some way this is the opposite of display: contents: it allows you to insert a box between an element and its children, without needing to change the HTML in non-semantic ways.
You can see all the details and examples in https://github.com/Loirooriol/css-contents, but the behavior is:
::contentshasdisplay: contentsby default, via a rule in the UA origin. This can be overridden so that it does generate boxes.::contentscan be styled with arbitrary properties.::contentshas no effect in replaced elements.::contentsinherits from its originating element.- Elements and text nodes inherit inheritable properties from the
::contentsoriginated by the parent element. For non-inherited properties, inheritance is directly from the parent element (to avoid breaking theinheritkeyword). - Alternatively, inheritance could be from
::contentsfor all properties, and assignall: inheritto::contentsin UA origin. - This pseudo-element does not affect selectors.
jonjohnjohnson, SelenIT, Zhang-Junzhi, garrettberg, inoas and 28 moredaiplusplus, kizu, bleper, refactorized and davherrmann
