Skip to content

Commit

Permalink
[css-nesting-1] demo the result of BEM style nesting (#6276)
Browse files Browse the repository at this point in the history
  • Loading branch information
argyleink committed Jun 12, 2021
1 parent be51879 commit e8e14b8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions css-nesting-1/Overview.bs
Expand Up @@ -304,6 +304,30 @@ Direct Nesting {#direct}
*/
</pre>

Note:
<a href="https://en.wikipedia.org/wiki/CSS#:~:text=bem%20(block%2C%20element%2C%20modifier)">BEM</a> authors often use preprocessors to
stay <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">dry</a>
within a file and selector context,
and preprocessors would concatenate the selectors like strings.
This however is not how it works in browsers. Authors may still practice BEM,
but the nested selector string building technique will need to stay a feature
of preprocessors.

For example:

<pre class=lang-css>
.foo {
color: blue;
&__bar { padding: 2ch; }
}
/* equivalent to
.foo { color: blue; }
__bar.foo { padding: 2ch; }
*/
</pre>

''__bar'' is a valid potential <a href="https://html.spec.whatwg.org/multipage/custom-elements.html">custom element</a>.

But the following are invalid:

<pre class=lang-css>
Expand Down

0 comments on commit e8e14b8

Please sign in to comment.