@@ -432,6 +432,94 @@ The Nesting At-Rule: ''@nest'' {#at-nest}
432432 </pre>
433433 </div>
434434
435+ Nesting Conditional Rules {#conditionals}
436+ -----------------------------------------------
437+
438+ A style rule can have any number of <a>conditional rules</a> inside of it, of any type,
439+ intermixed with any number of declarations, in any order.
440+
441+ The presence of a nested conditional engages the same logic as if ''@nest'' was present.
442+ The nested conditional rules must contain a <a>nesting selector</a> and follow the same
443+ rules as outlined in <a href="#direct">direct nesting</a> .
444+
445+ <div class="example">
446+ For example, the following conditional nestings are valid:
447+
448+ <pre class="lang-css">
449+ .foo {
450+ display: grid;
451+
452+ @media (orientation: landscape) {
453+ & {
454+ grid-auto-flow: column;
455+ }
456+ }
457+ }
458+ /* equivalent to
459+ .foo { display: grid; }
460+
461+ @media (orientation: landscape) {
462+ .foo {
463+ grid-auto-flow: column;
464+ }
465+ }
466+ */
467+
468+ .foo {
469+ color: red;
470+
471+ @media (min-width: 480px) {
472+ & > .bar,
473+ & > .baz {
474+ color: blue;
475+ }
476+ }
477+ }
478+ /* equivalent to
479+ .foo { color: red; }
480+
481+ @media (min-width: 480px) {
482+ .foo > :is(.bar, .baz) {
483+ color: blue;
484+ }
485+ }
486+ */
487+ </pre>
488+
489+ But the following are invalid:
490+
491+ <pre class=lang-css>
492+ .foo {
493+ display: grid;
494+
495+ @media (orientation: landscape) {
496+ grid-auto-flow: column;
497+ }
498+ }
499+ /* Invalid because there's no nesting selector */
500+
501+ .foo {
502+ color: red;
503+
504+ @media (min-width: 480px) {
505+ & h1, h2 { color: blue; }
506+ }
507+ }
508+ /* Invalid because not all selectors in the list
509+ contain a nesting selector */
510+
511+ .foo {
512+ color: red;
513+
514+ @nest @media (min-width: 480px) {
515+ & { color: blue; }
516+ }
517+ }
518+ /* Invalid because @nest expects a selector prelude,
519+ instead a conditional rule was provided */
520+ </pre>
521+ </div>
522+
435523Mixing Nesting Rules and Declarations {#mixing}
436524-----------------------------------------------
437525
@@ -440,7 +528,8 @@ Mixing Nesting Rules and Declarations {#mixing}
440528 intermixed with any number of declarations,
441529 in any order.
442530
443- The relative ordering of <a>nested style rules</a> and other declarations <strong> is</strong> important;
531+ The relative ordering of <a>nested style rules</a> , <a>nested conditional rules</a> and
532+ other declarations <strong> is</strong> important;
444533 it's possible for a given style rule and a <a>nested style rule</a> within it to match the same element,
445534 and if the specificity of the two rules is otherwise equivalent,
446535 the relative order in the stylesheet of the applicable declarations
0 commit comments