Careeroza
Naming with BEM
Block, Element, Modifier
BEM is a naming convention that keeps class names clear and specificity flat:
| Part | Pattern | Example |
|---|---|---|
| Block | a standalone component | .card |
| Element | a part of a block: block__element | .card__title, .card__button |
| Modifier | a 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.