W3C home > Mailing lists > Public > public-css-archive@w3.org > April 2017

[csswg-drafts] [css-content][css-pseudo][css-cascade] Does content:contents in pseudo affect inheritance?

From: Loirooriol via GitHub <sysbot+gh@w3.org>
Date: Sun, 09 Apr 2017 23:39:18 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-220508811-1491781157-sysbot+gh@w3.org>
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-content][css-pseudo][css-cascade] Does content:contents in pseudo affect inheritance? ==
[CSS Content](https://drafts.csswg.org/css-content/#element-content) allows to move the actual contents of an element into the ::before or ::after pseudo-element.

How does this affect inheritance? Do the actual contents of the element still inherit from the element, or do they inherit from the pseudo-element?

For example:

```css
div {
  content: none;
  color: red;
}
div::before {
  content: contents;
  color: green;
}
```
```html
<div><span>Foo</span></div>
```

Should Foo be green or red? On the one hand, [CSS Cascade](https://drafts.csswg.org/css-cascade-4/#inheritance) says

> Note: Inheritance follows the document tree and is not intercepted by anonymous boxes, or otherwise affected by manipulations of the box tree.

so maybe the span should inherit from the div and be red. On the other hand, [CSS Pseudo](https://drafts.csswg.org/css-pseudo-4/#generated-content) says

> these pseudo-elements generate boxes as if they were immediate children of their originating element, and can be styled exactly like any normal document-sourced element in the document tree.

Personally I would expect green, like if I had used `content: "Foo"` instead of `content: contents`.
As far as I know, there is no implementation of this to test.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1195 using your GitHub account
Received on Sunday, 9 April 2017 23:39:25 UTC

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