This is not an opinion question. I'm trying to understand what's the advantage of BEM convention. I can't figure it out. Can you point me to the right direction?
Without BEM:
<div class="menu">
<a class="item active" href="#">Link 1</a>
<a class="item" href="#">Link 2</a>
</div>
.menu {
background-color: red;
.item {
background-color: green;
.active {
color: red;
}
}
}
With BEM:
<div class="menu">
<a class="menu__item--active" href="#">Link 1</a>
<a class="menu__item" href="#">Link 2</a>
</div>
.menu {
background-color: red;
&__item {
background-color: green
&--active {
color: red;
}
}
}
What's the point of having a selector .menu .menu__item
over .menu .item
? What's the reason I need to write more?