CSS rots when class names collide and selectors nest deep. BEM is the naming discipline that prevents it โ and it appears in tons of codebases you'll join.
The three parts
/* Block โ standalone component */
.card { }
/* Element โ a part of the block (double underscore) */
.card__title { }
.card__image { }
.card__button { }
/* Modifier โ a variant (double dash) */
.card--featured { }
.card__button--disabled { }<article class="card card--featured"> <img class="card__image" src="..."> <h3 class="card__title">Title</h3> <button class="card__button card__button--disabled">Read</button> </article>
What it buys you
- Flat specificity: every selector is one class โ no
.page .sidebar div h3fights - Self-documenting:
card__titletells you exactly where it belongs - Grep-able: search a class name, find its one definition
Pragmatic notes
Don't nest elements in names (card__header__title โ โ card__title โ
). Modern alternatives (CSS Modules, Tailwind, scoped styles) solve the same problem with tooling โ BEM solves it with discipline alone, which is why it survives.