Skip to content

Commit 183a548

Browse files
committed
[css-cascade-5] Move unlayered styles below explicit layers by default #6284
1 parent 6bee7dc commit 183a548

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

css-cascade-5/Overview.bs

+35-23
Original file line numberDiff line numberDiff line change
@@ -1190,27 +1190,27 @@ Cascade Layers</h3>
11901190
or relying on source-order to resolve conflicts across layers.
11911191

11921192
<div class="example">
1193-
For example, the following generates an explicit ''defaults'' layer,
1194-
with lower cascade weight than any un-layered styles:
1193+
For example, the following generates an explicit ''utilities'' layer,
1194+
with higher cascade weight than any un-layered styles:
11951195

11961196
<pre class='lang-css'>
1197-
audio {
1198-
/* specificity of 0,0,1 - implicit (final) layer */
1199-
display: flex;
1197+
@layer utilities {
1198+
.padding-small {
1199+
/* specificity of 0,1,0 - explicit "utilities" layer */
1200+
padding: 0.25em;
1201+
}
12001202
}
12011203

1202-
@layer defaults {
1203-
audio[controls] {
1204-
/* specificity of 0,1,1 - explicit "defaults" layer */
1205-
display: block;
1206-
}
1204+
.card > .content {
1205+
/* specificity of 0,2,0 - implicit (first) layer */
1206+
padding: 1em;
12071207
}
12081208
</pre>
12091209

1210-
The un-layered declarations on the <{audio}> element take precedence
1211-
over the explicitly layered declarations on ''audio[controls]'' --
1212-
even though the un-layered styles have a lower specificity,
1213-
and come first in the source order.
1210+
The explicitly layered declarations on <code>.padding-small</code> take precedence
1211+
over the un-layered declarations on the <code>.card > .content</code> element --
1212+
even though the un-layered styles have a higher specificity,
1213+
and come later in the source order.
12141214
</div>
12151215

12161216
<h4 id="layer-declaration">
@@ -1421,7 +1421,7 @@ Layer Ordering</h4>
14211421
Cascade layers are sorted
14221422
by the order in which they first are declared,
14231423
with nested layers grouped within their parent layers
1424-
before any unlayered rules.
1424+
after any unlayered rules.
14251425

14261426
<div class="example">
14271427
Given the following layer rules:
@@ -1442,22 +1442,30 @@ Layer Ordering</h4>
14421442
h1, h2 { color: maroon; }
14431443
}
14441444
}
1445+
1446+
/* unlayered styles come first in the layer order */
1447+
h1 { color: darkslateblue; }
14451448
</pre>
14461449

1447-
The outer layers are sorted first:
1450+
The outer layers are sorted first,
1451+
with any unlayered style rules
1452+
added to an implicit outer layer which
1453+
has lower priority (comes before) the explicit layers:
14481454

1449-
1. ''framework''
1450-
2. ''utilities''
1455+
1. (implicit outer layer)
1456+
2. ''framework''
1457+
3. ''utilities''
14511458

14521459
Within each layer,
14531460
nested layers are sorted in appearance order,
14541461
and style rules without further nesting
1455-
are added to an implicit sub-layer which
1456-
takes priority over (comes after) explicitly nested layers:
1462+
are similarly added to an implicit sub-layer
1463+
before the explicitly nested layers:
14571464

1458-
1. ''framework.default''
1459-
2. ''framework.theme''
1460-
3. ''framework'' (implicit sub-layer)
1465+
1. (implicit outer layer)
1466+
2. ''framework'' (implicit sub-layer)
1467+
2. ''framework.default''
1468+
3. ''framework.theme''
14611469
4. ''utilities''
14621470
</div>
14631471

@@ -1466,6 +1474,8 @@ Layer Ordering</h4>
14661474
on the order of identically-named layers in the shadow DOM
14671475
(and vice versa).
14681476

1477+
Issue(6323): Allow authors to explicitly place unlayered styles in the layer order
1478+
14691479
<h4 id="at-layer">
14701480
Declaring Layers Inline: the ''@layer'' rule</h4>
14711481

@@ -1742,6 +1752,8 @@ Changes</h2>
17421752
(<a href="https://github.com/w3c/csswg-drafts/issues/5681">Issue 5681</a>)
17431753
* Added ''revert-layer'' keyword.
17441754
(<a href="https://github.com/w3c/csswg-drafts/issues/5793">Issue 5793</a>)
1755+
* Switched the ordering of unlayered styles
1756+
from highest to lowest priority in the normal origins.
17451757

17461758
<h3 id="additions-l4">
17471759
Additions Since Level 4</h3>

0 commit comments

Comments
 (0)