๐Ÿท๏ธ CSS

BEM Naming Convention โ€” Organize CSS That Doesn't Rot

๐Ÿ“… Jul 3, 2026 โฑ 3 min read

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

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.

โ† All Articles