@@ -1507,6 +1507,49 @@ Layer Ordering</h4>
1507
1507
4. ''utilities''
1508
1508
</div>
1509
1509
1510
+ Layers that are defined inside of a [=conditional group rule=]
1511
+ do not contribute to the layer order unless the condition is true,
1512
+ or the [=conditional group rule=] evaluates contextually
1513
+ for different elements on the page.
1514
+
1515
+ Note: A feature like "container queries"
1516
+ would need to evaluate contextually for individual elements.
1517
+ Because of that, layers defined inside a container query
1518
+ would be considered part of the global layer order
1519
+ regardless of the condition.
1520
+
1521
+ <div class=example>
1522
+ For example,
1523
+ the following layer order
1524
+ will depend on which media conditions match:
1525
+
1526
+ <pre class='lang-css'>
1527
+ @media (min-width: 30em) {
1528
+ @layer layout {
1529
+ .title { font-size: x-large; }
1530
+ }
1531
+ }
1532
+
1533
+ @media (prefers-color-scheme: dark) {
1534
+ @layer theme {
1535
+ .title { color: white; }
1536
+ }
1537
+ }
1538
+
1539
+ @layer theme layout;
1540
+ </pre>
1541
+
1542
+ If the first media-query matches based on viewport dimensions,
1543
+ then the ''layout'' layer will come first in the layer order.
1544
+ If the color-scheme preference query matches,
1545
+ or if neither condition is true,
1546
+ then ''theme'' will come first in the layer order.
1547
+
1548
+ Authors who want to avoid this behavior can establish
1549
+ an explicit ordering of layers in advance,
1550
+ and avoid defining new layers inside conditional rules.
1551
+ </div>
1552
+
1510
1553
Note: [=Cascade layers=] are scoped to their [=origin=] and [=context=] ,
1511
1554
so the ordering of layers in the light DOM has no impact
1512
1555
on the order of identically-named layers in the shadow DOM
0 commit comments