Answer the question
In order to leave comments, you need to log in
What is the correct way to name classes in BEM?
Greetings! I watched a bunch of videos, read a huge number of articles on BEM, but there is still no complete picture of the class naming issue. That's what I'm talking about, according to the logic, the naming of classes in BEM occurs according to this logic: block__element--modifier
in this case, in my example it should be:
.menu {}
.menu__item {}
.menu__item--active {}
.menu__link
.menu {}
.menu__item {}
.menu_item_acitve {}
.menu__link
Answer the question
In order to leave comments, you need to log in
Below in the comments is an explanation that in English. The network got accustomed to the spelling not the cat. was originally. frontender.info/learning-to-love-bem
That's why there are differences. But the essence is the same
I recommend naming the classes in a way that is convenient for you personally (or your team).
Personally, I really dislike entries with double dashes or underscores, and even more so key-value modifiers. It looks very cumbersome, especially when one element has several similar classes.
.menu__item--active {}
.menu__item_state_active {}
Although there is a solution for a long time, I will clarify a little and correct the question itself - if anyone else asks such a question.
Strictly speaking, in the original BEM notation, the class .menu_item_active {}
will look like .menu__item_state_active {}
.
This is a case of a key/value type modifier whose fully qualified name is constructed as follows: block-name__elem-name_mod-name_mod-val
.
Therefore, not btn_big_red
, but btn_color_red
and btn_size_big
, that is, there are already 2 modifiers.
More details - in the naming convention , at the very bottom there is also a section "Alternative names"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question