Answer the question
In order to leave comments, you need to log in
How to name elements when using block modifier in BEM?
Good day everyone!
BEM is a new person, so every now and then questions arise. Today appeared this:
For example, I have a menu
nav.menu
a.menu__element(href="#") Пункт 1
a.menu__element(href="#") Пункт 2
a.menu__element(href="#") Пункт 3
nav.menu.menu_theme_red
a.menu__element(href="#").menu__element_color_white Пункт 1
a.menu__element(href="#").menu__element_color_white Пункт 2
a.menu__element(href="#").menu__element_color_white Пункт 3
nav.menu.menu_theme_red
a.menu__element(href="#") Пункт 1
a.menu__element(href="#") Пункт 2
a.menu__element(href="#") Пункт 3
.menu_theme_red
background: #f00
.menu_theme_red > .menu__element
color: #fff
Answer the question
In order to leave comments, you need to log in
It will be correct to modify or mix each element. Use nesting only as a last resort when there are no other options. If you use css variables that are set in the parent, then in this case you can do without modifiers for elements, you can also inherit the color and font from the parent so as not to set unnecessary modifiers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question