BEM — is a methodology that helps you to create reusable components and code sharing in front‑end development
Learn why it's betterClassic CSS
#opinions_box h1 {
margin: 0 0 8px 0;
text-align: center;
}
#opinions_box {
p.more_pp {
a {
text-decoration: underline;
}
}
input[type="text"] {
border: 1px solid #ccc!important;
}
}
BEM
.opinions_box {
margin: 0 0 8px 0;
text-align: center;
&__view-more {
text-decoration: underline;
}
&__text-input {
border: 1px solid #ccc;
}
&--is-inactive {
color: gray;
}
}
Easy
To use BEM, you only need to employ BEM’s naming convention.
Modular
Independent blocks and CSS selectors make your code reusable and modular.
Flexible
Using BEM, methodologies and tools can be recomposed and configured the way you like.