Answer the question
In order to leave comments, you need to log in
How to write the name of the BEM classes correctly?
Hello.
There is a code example.
<div class="menu">
<div class="menu__links">
<a class="menu__links-item" href="/">Item 1</a>
<a class="menu__links-item" href="/">Item 2</a>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
It's more of a matter of agreement. In our team, it is customary to use a two-level BEM tree - i.e. do not bind to the name of the parent element, so more flexible.
If the class of the list and its child element differ by only one letter (plural and singular), they are easy to confuse: .menu__items
and .menu__item
, so better: ul.menu__list > li.menu__item
or div.menu__list > a.menu__link
etc.
Example:
<div class="menu">
<div class="menu__list">
<a class="menu__item" href="/">Item 1</a>
<a class="menu__item" href="/">Item 2</a>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question