diff --git a/css-nesting-1/Overview.bs b/css-nesting-1/Overview.bs index 5b6bbec2216..4ec29682d67 100644 --- a/css-nesting-1/Overview.bs +++ b/css-nesting-1/Overview.bs @@ -432,6 +432,94 @@ The Nesting At-Rule: ''@nest'' {#at-nest} +Nesting Conditional Rules {#conditionals} +----------------------------------------------- + + A style rule can have any number of conditional rules inside of it, of any type, + intermixed with any number of declarations, in any order. + + The presence of a nested conditional engages the same logic as if ''@nest'' was present. + The nested conditional rules must contain a nesting selector and follow the same + rules as outlined in direct nesting. + +
+ .foo {
+ display: grid;
+
+ @media (orientation: landscape) {
+ & {
+ grid-auto-flow: column;
+ }
+ }
+ }
+ /* equivalent to
+ .foo { display: grid; }
+
+ @media (orientation: landscape) {
+ .foo {
+ grid-auto-flow: column;
+ }
+ }
+ */
+
+ .foo {
+ color: red;
+
+ @media (min-width: 480px) {
+ & > .bar,
+ & > .baz {
+ color: blue;
+ }
+ }
+ }
+ /* equivalent to
+ .foo { color: red; }
+
+ @media (min-width: 480px) {
+ .foo > :is(.bar, .baz) {
+ color: blue;
+ }
+ }
+ */
+
+
+ But the following are invalid:
+
+
+ .foo {
+ display: grid;
+
+ @media (orientation: landscape) {
+ grid-auto-flow: column;
+ }
+ }
+ /* Invalid because there's no nesting selector */
+
+ .foo {
+ color: red;
+
+ @media (min-width: 480px) {
+ & h1, h2 { color: blue; }
+ }
+ }
+ /* Invalid because not all selectors in the list
+ contain a nesting selector */
+
+ .foo {
+ color: red;
+
+ @nest @media (min-width: 480px) {
+ & { color: blue; }
+ }
+ }
+ /* Invalid because @nest expects a selector prelude,
+ instead a conditional rule was provided */
+
+