Skip to content

[css-nesting-1] Invalid nested selectors #7503

Closed
@cdoublev

Description

@cdoublev

I think CSS Nesting or CSS Selector 4 (probably the former) should clarify something like "An invalid complex or compound selector remains invalid when some of its parts are nested":

::before {
  &:hover {} /* valid */
  & div {} /* invalid */
}

Currently, in CSS Selector 4:

A pseudo-element may be immediately followed by any combination of the user action pseudo-classes [...].

Note that, unless otherwise specified in a future specification, pseudo-classes other than the user action pseudo-classes are not valid when compounded to a pseudo-element; so, for example, ::before:first-child is an invalid selector.

Some pseudo-elements are defined to have internal structure. These pseudo-elements may be followed by child/descendant combinators to express those relationships. Selectors containing combinators after the pseudo-element are otherwise invalid.

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