Skip to content

Commit e8e14b8

Browse files
authored
[css-nesting-1] demo the result of BEM style nesting (w3c#6276)
1 parent be51879 commit e8e14b8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

css-nesting-1/Overview.bs

+24
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,30 @@ Direct Nesting {#direct}
304304
*/
305305
</pre>
306306

307+
Note:
308+
<a href="https://en.wikipedia.org/wiki/CSS#:~:text=bem%20(block%2C%20element%2C%20modifier)">BEM</a> authors often use preprocessors to
309+
stay <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">dry</a>
310+
within a file and selector context,
311+
and preprocessors would concatenate the selectors like strings.
312+
This however is not how it works in browsers. Authors may still practice BEM,
313+
but the nested selector string building technique will need to stay a feature
314+
of preprocessors.
315+
316+
For example:
317+
318+
<pre class=lang-css>
319+
.foo {
320+
color: blue;
321+
&__bar { padding: 2ch; }
322+
}
323+
/* equivalent to
324+
.foo { color: blue; }
325+
__bar.foo { padding: 2ch; }
326+
*/
327+
</pre>
328+
329+
''__bar'' is a valid potential <a href="https://html.spec.whatwg.org/multipage/custom-elements.html">custom element</a>.
330+
307331
But the following are invalid:
308332

309333
<pre class=lang-css>

0 commit comments

Comments
 (0)