Naming with BEM

Block, Element, Modifier

BEM is a naming convention that keeps class names clear and specificity flat:

PartPatternExample
Blocka standalone component.card
Elementa part of a block: block__element.card__title, .card__button
Modifiera variant: block--modifier.card--featured
<article class="card card--featured">
  <h3 class="card__title">CSS Course</h3>
  <a class="card__button" href="#">Start</a>
</article>

Why It Helps

  • Every selector is a single class: equal specificity, no fights.
  • You can tell from the HTML which CSS applies.
  • Components can be moved anywhere without breaking.