W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2018

[csswg-drafts] [css-pseudo] Add a ::contents pseudo-element

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Tue, 06 Mar 2018 18:29:21 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-302814949-1520360960-sysbot+gh@w3.org>
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-pseudo] Add a ::contents pseudo-element ==
Some years ago I proposed a [`::contents` pseudo-element](https://lists.w3.org/Archives/Public/www-style/2015Oct/0105.html). I have been refining the details in https://github.com/Loirooriol/css-contents, and yesterday someone proposed [the same idea](https://lists.w3.org/Archives/Public/www-style/2018Mar/0010.html), 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:

 - `::contents` has `display: contents` by default, via a rule in the UA origin. This can be overridden so that it does generate boxes.
 - `::contents` can be styled with arbitrary properties.
 - `::contents` has no effect in replaced elements.
 - `::contents` inherits from its originating element.
 - Elements and text nodes inherit inheritable properties from the `::contents` originated by the parent element. For non-inherited properties, inheritance is directly from the parent element (to avoid breaking the `inherit` keyword).
 - Alternatively, inheritance could be from `::contents` for all properties, and assign `all: inherit` to `::contents` in UA origin.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2406 using your GitHub account
Received on Tuesday, 6 March 2018 18:29:24 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:26 UTC