[csswg-drafts] [css-cascade] What is a valid at-rule? Or what is an invalid at-rule? (#9175)

romainmenke has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade] What is a valid at-rule? Or what is an invalid at-rule? ==
https://drafts.csswg.org/css-cascade-5/#at-import

> Any `@import` rules must precede all other valid at-rules and style rules in a style sheet (ignoring `@charset` and `@layer` statement rules) and must not have any other valid at-rules or style rules between it and previous `@import` rules, or else the `@import` rule is invalid.

After reading this I was curious what the exact definition is for a valid at-rule.

I assume that the intention is to allow new at-rules to be added to the language later without invalidating all imports in older browser versions.

It wasn't immediately clear to me exactly when an at-rule becomes invalid.

Is it only when the at-keyword-token is unknown? (e.g. `@unknown {}`)

-----

Things I noticed I could place before an `@import` and still have it apply :

```css
@unknown {}

@import url("./red.css");
```

```css
@ {}

@import url("./red.css");
```

```css
{}

@import url("./red.css");
```

------



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9175 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 9 August 2023 21:12:00 UTC