Skip to content

[css-nesting-1] Behavior of nesting within pseudo element selectors #7912

@sesse

Description

@sesse

What is the correct behavior of this?

<style>
div::before {
  & {
    content: "test";
  }
}
</style>
<div>xyz</div>

FWIW, my preferred resolution would be “inner rule matches nothing”, since pseudo element selectors are not allowed within :is() and & is generally defined in terms of :is(), but the spec is not clear on this (it doesn't define & as exactly equivalent to :is(), just that it matches the elements of the parent rule and has the same specificity).

The other two alternatives would be either parse error (difficult when taking CSSOM into account) or that it actually would be equivalent with writing out div::before (problematic when combining & with further selectors).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions