Skip to content

[css-nesting-1] Clarify valid position of & in a selector #9940

Closed
@cdoublev

Description

@cdoublev

CSS Nesting does not clearly define where & is allowed to appear in a selector. In Chrome/FF, these selectors are all invalid:

  • html|&
  • html&|*
  • #&id
  • .&class
  • [&]
  • [attr=&]
  • [attr=value &]

While the position of & does not make a difference in its behavior, it should only match <type-selector> and <subclass-selector> in <compound-selector>.


I would also like to suggest to define this again (cf. #7503):

An invalid selector remains invalid when some of its parts are nested.

In Chrome/FF, the nested rule in ::before, div { &:first-child {} } is valid whereas the version without nesting, ::before:first-child, div:first-child {} is not (because :first-child is not allowed to be compounded to ::before).

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