Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions plugins/postcss-nesting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ Future versions of this plugin will first warn and then error if you use `@nest`

We advice everyone to migrate their codebase **now** to nested CSS without `@nest`.

## ⚠️ Nested selectors must start with a symbol

The current version of the [CSS Nesting specification](https://www.w3.org/TR/2023/WD-css-nesting-1-20230214/#example-34e8e94f) disallows nested selectors to start with a letter (i.e. a tag name or element selector). To write such selectors, they need to be prefixed with `& ` or wrapped with `:is()`.

You will get a warning when selectors start with a letter:
> Nested selectors must start with a symbol and "span" begins with a letter.

```pcss
.foo {
/* ❌ invalid */
span {
color: hotpink;
}

/* ✅ valid */
& span {
color: hotpink;
}

/* ❌ invalid */
span & {
color: hotpink;
}

/* ✅ valid */
:is(span) & {
color: hotpink;
}
}
```

## Options

Expand Down
30 changes: 30 additions & 0 deletions plugins/postcss-nesting/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ Future versions of this plugin will first warn and then error if you use `@nest`

We advice everyone to migrate their codebase **now** to nested CSS without `@nest`.

## ⚠️ Nested selectors must start with a symbol

The current version of the [CSS Nesting specification](https://www.w3.org/TR/2023/WD-css-nesting-1-20230214/#example-34e8e94f) disallows nested selectors to start with a letter (i.e. a tag name or element selector). To write such selectors, they need to be prefixed with `& ` or wrapped with `:is()`.

You will get a warning when selectors start with a letter:
> Nested selectors must start with a symbol and "span" begins with a letter.

```pcss
.foo {
/* ❌ invalid */
span {
color: hotpink;
}

/* ✅ valid */
& span {
color: hotpink;
}

/* ❌ invalid */
span & {
color: hotpink;
}

/* ✅ valid */
:is(span) & {
color: hotpink;
}
}
```

## Options

Expand Down