Skip to content

[css-nesting-1] Should prefixing nested selectors be mandatory? #8270

@SebastianZ

Description

@SebastianZ

As mentioned in #8248, some people expressed support for making the ampersand in nested rule selectors mandatory. Some discussion already happened in the other issue, though here's a summary of its advantages and disadvantages:

Advantages:

  • Clarity for authors and readers (e.g. &::before vs. & ::before)
  • Allows support for full selector syntax (including type selectors)
  • Lets UAs still distinguish selectors from property declarations on the first character even with type selector support

Disadvantages:

  • Confusing for authors when using & later in the selector (in case & is used as prefix and reference for elements matched by the parent rule)
  • More to write for authors
  • Unnecessary regarding parsing (except for type selectors)

Sebastian

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