Skip to content

[css-content][css-pseudo][css-cascade] Does content:contents in pseudo affect inheritance? #1195

@Loirooriol

Description

@Loirooriol

CSS 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:

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

Should Foo be green or red? On the one hand, CSS Cascade 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 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions