Skip to content

Commit 7726486

Browse files
committed
[css-cascade-5][editorial] Clarify ordering requirements in example
1 parent 160e621 commit 7726486

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

css-cascade-5/Overview.bs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,8 @@ Declaring Without Styles: the ''@layer'' statement at-rule</h5>
16191619
(after the ''@charset'' rule, if any)
16201620
as well as everywhere ''@layer'' [=block at-rules=] are allowed.
16211621

1622-
Note: Empty ''@layer'' rules are not allowed between ''@import'' and ''@namespace'' rules.
1623-
A ''@layer'' rule that comes after an ''@import'' or ''@namespace'' rule
1622+
Note: No ''@layer'' rules are allowed between ''@import'' and ''@namespace'' rules.
1623+
Any ''@layer'' rule that comes after an ''@import'' or ''@namespace'' rule
16241624
will cause any subsequent ''@import'' or ''@namespace'' rules to be ignored.
16251625

16261626
Unlike the [[#layer-block|block syntax]],
@@ -1638,16 +1638,16 @@ Declaring Without Styles: the ''@layer'' statement at-rule</h5>
16381638
The statement syntax
16391639
allows establishing a layer order in advance,
16401640
regardless of the order in which style rules are added to each layer.
1641-
1641+
It can be helpful to establish that layer order in advance,
1642+
before any ''@import'' rules.
16421643
In this example,
16431644
the imported <code>theme.css</code> style rules will override
16441645
any rules added in the later <css>default</css> block
1645-
since the order of layers has already been established.
1646+
since the order of layers has already been established:
16461647

16471648
<pre class='lang-css'>
1648-
@layer default;
1649+
@layer default, theme, components;
16491650
@import url(theme.css) layer(theme);
1650-
@layer components;
16511651

16521652
@layer default {
16531653
audio[controls] {
@@ -1656,23 +1656,40 @@ Declaring Without Styles: the ''@layer'' statement at-rule</h5>
16561656
}
16571657
</pre>
16581658

1659-
It can also be written with the comma-separated syntax as:
1659+
It's also possible to have ''@import'' rules
1660+
help establish the order,
1661+
by placing them between ''@layer'' rules.
1662+
This example will have the same result:
16601663

16611664
<pre class='lang-css'>
1662-
@layer default, theme, components;
1665+
@layer default;
16631666
@import url(theme.css) layer(theme);
1667+
@layer components;
16641668

16651669
@layer default {
16661670
audio[controls] {
16671671
display: block;
16681672
}
16691673
}
16701674
</pre>
1671-
</div>
1672-
16731675

1676+
However,
1677+
''@import'' and ''@namespace'' rules must be consecutive,
1678+
without any intervening rules.
1679+
The following is invalid:
16741680

1681+
<pre class='lang-css'>
1682+
@import url(default.css) layer(default);
1683+
@layer theme;
1684+
@import url(components.css) layer(components);
16751685

1686+
@layer theme {
1687+
audio[controls] {
1688+
display: block;
1689+
}
1690+
}
1691+
</pre>
1692+
</div>
16761693

16771694

16781695
<h3 id="preshint">

0 commit comments

Comments
 (0)