Skip to content

Commit a6fc16e

Browse files
committed
[css-cascade-5] Revert the ordering of unlayered styles #6284
1 parent 217feeb commit a6fc16e

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

css-cascade-5/Overview.bs

+43-42
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ Cascade Sorting Order</h3>
10171017
can be explicitly assigned to a [=cascade layer=].
10181018
For the purpose of this step,
10191019
any declaration not assigned to an explicit layer
1020-
is added to an implicit first layer.
1020+
is added to an implicit final layer.
10211021

10221022
Cascade layers (like declarations) are ordered by order of appearance.
10231023
When comparing declarations that belong to different layers,
@@ -1196,27 +1196,27 @@ Cascade Layers</h3>
11961196
or relying on source-order to resolve conflicts across layers.
11971197

11981198
<div class="example">
1199-
For example, the following generates an explicit ''utilities'' layer,
1200-
with higher cascade weight than any un-layered styles:
1199+
For example, the following generates an explicit ''reset'' layer,
1200+
with lower cascade weight than any unlayered styles:
12011201

12021202
<pre class='lang-css'>
1203-
@layer utilities {
1204-
.padding-small {
1205-
/* specificity of 0,1,0 - explicit "utilities" layer */
1206-
padding: 0.25em;
1207-
}
1208-
}
1203+
audio {
1204+
/* specificity of 0,0,1 - implicit (final) layer */
1205+
display: flex;
1206+
}
12091207

1210-
.card > .content {
1211-
/* specificity of 0,2,0 - implicit (first) layer */
1212-
padding: 1em;
1213-
}
1208+
@layer reset {
1209+
audio[controls] {
1210+
/* specificity of 0,1,1 - explicit "reset" layer */
1211+
display: block;
1212+
}
1213+
}
12141214
</pre>
12151215

1216-
The explicitly layered declarations on <code>.padding-small</code> take precedence
1217-
over the un-layered declarations on the <code>.card > .content</code> element --
1218-
even though the un-layered styles have a higher specificity,
1219-
and come later in the source order.
1216+
The unlayered declarations on the <{audio}> element take precedence
1217+
over the explicitly layered declarations on <code>audio[controls]</code> --
1218+
even though the unlayered styles have a lower specificity,
1219+
and come first in the source order.
12201220
</div>
12211221

12221222
Name-defining [=at-rules=]
@@ -1467,52 +1467,52 @@ Layer Ordering</h4>
14671467
Cascade layers are sorted
14681468
by the order in which they first are declared,
14691469
with nested layers grouped within their parent layers
1470-
after any unlayered rules.
1470+
before any unlayered rules.
14711471

14721472
<div class="example">
14731473
Given the following layer rules:
14741474

14751475
<pre class='lang-css'>
1476-
@layer framework.default {
1477-
strong { font-weight: bold; }
1478-
}
1476+
/* unlayered styles come last in the layer order */
1477+
h1 { color: darkslateblue; }
14791478

1480-
@layer utilities {
1481-
[hidden] { display: none; }
1482-
}
1479+
@layer reset.type {
1480+
strong { font-weight: bold; }
1481+
}
14831482

1484-
@layer framework {
1485-
.title { font-weight: 100; }
1483+
@layer framework {
1484+
.title { font-weight: 100; }
14861485

1487-
@layer theme {
1488-
h1, h2 { color: maroon; }
1489-
}
1490-
}
1486+
@layer theme {
1487+
h1, h2 { color: maroon; }
1488+
}
1489+
}
14911490

1492-
/* unlayered styles come first in the layer order */
1493-
h1 { color: darkslateblue; }
1491+
@layer reset {
1492+
[hidden] { display: none; }
1493+
}
14941494
</pre>
14951495

14961496
The outer layers are sorted first,
14971497
with any unlayered style rules
14981498
added to an implicit outer layer which
1499-
has lower priority (comes before) the explicit layers:
1499+
has higher priority than (comes after) the explicit layers:
15001500

1501-
1. (implicit outer layer)
1501+
1. ''reset''
15021502
2. ''framework''
1503-
3. ''utilities''
1503+
3. (implicit outer layer)
15041504

15051505
Within each layer,
15061506
nested layers are sorted in appearance order,
15071507
and style rules without further nesting
15081508
are similarly added to an implicit sub-layer
1509-
before the explicitly nested layers:
1509+
after the explicitly nested layers:
15101510

1511-
1. (implicit outer layer)
1512-
2. ''framework'' (implicit sub-layer)
1513-
2. ''framework.default''
1511+
1. ''reset.type''
1512+
2. ''reset'' (implicit sub-layer)
15141513
3. ''framework.theme''
1515-
4. ''utilities''
1514+
4. ''framework'' (implicit sub-layer)
1515+
5. (implicit outer layer)
15161516
</div>
15171517

15181518
Layers that are defined inside of a [=conditional group rule=]
@@ -1864,8 +1864,9 @@ Changes since the 29 August 2021 Working Draft</h3>
18641864

18651865
Changes since the <a href="https://www.w3.org/TR/2021/WD-css-cascade-5-20210608/">8 June 2021 Working Draft</a> include:
18661866

1867-
* Fixed a missed edit for switching ordering of unlayered styles.
1868-
(See [[#changes-2021-06]].)
1867+
* Revert the ordering of unlayered styles.
1868+
(See [[#changes-2021-06]] and
1869+
<a href="https://github.com/w3c/csswg-drafts/issues/6284">Issue 6284</a>)
18691870

18701871
<h3 id="changes-2021-08">
18711872
Changes since the 8 June 2021 Working Draft</h3>

0 commit comments

Comments
 (0)