sass/spec/selectors.md
Natalie Weizenbaum 90948b384a
Flush plain CSS nesting changes to the spec (#3841)
Closes #3524

Co-authored-by: Carlos (Goodwine) <2022649+Goodwine@users.noreply.github.com>
2024-04-19 23:17:11 +00:00

2.4 KiB

Selectors

Table of Contents

Definitions

Visible Combinator

A visible combinator is any selector combinator other than the descendant combinator.

Complex Selector

A complex selector is an optional visible combinator (its leading combinator) as well as a sequence of complex selector components. The component sequence may be empty only for complex selectors with leading combinators.

Complex Selector Component

A complex selector component is a compound selector as well as a single combinator.

Trailing Combinator

A complex selector's trailing combinator is its final complex selector component's combinator if it's not a descendant combinator. If it is a descendant combinator, the complex selector doesn't have a trailing combinator.

Bogus Selector

A complex selector is bogus if it has a leading or trailing combinator, or if any of the simple selectors it transitively contains is a selector pseudo with a bogus selector, except that :has() may contain complex selectors with leading combinators.

A selector list is bogus if any of its complex selectors are bogus.

Syntax

ComplexSelector

ComplexSelector          ::= <combinator>? ComplexSelectorComponent+
                           | <combinator>
ComplexSelectorComponent ::= CompoundSelector <combinator>?

Serialization

Parent Selector

To serialize a parent selector, emit the character &.

A parent selector can only appear in a serialized selector if it was parsed from plain CSS, which doesn't allow it to have a suffix.