The BEM methodology is used for building components. BEM stands for “Block, Element, Modifier”. This principle helps naming components in consistent ways.
Blocks are the top-level component name. Elements are inside the component and are prefixed with the component name. Modifiers can be used to allow different styling of each component.
A pragmatic approach should be taken when writing the markup with BEM. Not everything will need a specific class, child combinator and adjacent sibling combinator selectors could be used to target the required elements.
Below is a code example of HTML
using BEM.
<div class="item">
<h4 class="item__heading"></h4>
<p class="item__content"></p>
</div>
<div class="item item--alt">
<h4 class="item__heading"></h4>
<p class="item__content"></p>
</div>
<nav class="navigation">
<ul>
<li class="navigation__item">
<a href="#"></a>
</li>
<li class="navigation__item navigation__item--active">
<a href="#"></a>
</li>
<li class="navigation__item">
<a href="#"></a>
</li>
</ul>
</nav>