BEM (Block Element Modifier) Methodology
You'll learn how BEM naming gives your CSS classes clear, predictable names that describe exactly what they do and where they belong.
What Is BEM?
BEM is a naming convention that turns your CSS classes into self-documenting code. Instead of vague names like .title or .big-text, BEM creates structured names that tell you three things: which component it belongs to (Block), what part of that component it is (Element), and any variations it might have (Modifier).
Think of it like naming files on your computer: instead of document.pdf, you might use 2024-project-proposal-final.pdf — much more informative!
The Three Parts
Block: The standalone component or container. Example: .card, .menu, .search-form
Element: A part inside the block that doesn't make sense on its own. Connected with double underscores: .card__title, .menu__item, .search-form__input
Modifier: A variation or state of a block or element. Connected with double dashes: .card--featured, .menu__item--active, .search-form--compact
Real-World Example
.article { }
.article__heading { }
.article__body { }
.article__author { }
.article--featured { }
.article__heading--large { }
You instantly know that article__heading--large is a large-styled heading element inside an article block. No confusion about hierarchy or relationships.
Why It Works
BEM eliminates naming conflicts because every class is unique and scoped to its component. There's no cascade confusion — .article__title will never accidentally style .card__title. Your CSS becomes modular: you can drop an entire block into any project and it works independently.
Key Takeaway: BEM creates self-documenting CSS through structured naming (Block__Element--Modifier) that makes components portable, predictable, and collision-proof.