BEM
noun
say it: “BEM” /bɛm/ or “BEE EE EM” /ˌbiː iː ˈɛm/
Block, Element, Modifier: a way of naming CSS classes as block__element--modifier, so every class says which component it belongs to and which version it is.
What is BEM?
BEM (Block, Element, Modifier) is a way of naming CSS classes. The block is the component (event-card), an element is a part of it, after two underscores (event-card__title), and a modifier is a version of it, after two dashes (event-card--featured). Every selector is one class, so they stay short and easy to beat.
<article class="event-card event-card--featured">
<h3 class="event-card__title">Story Time for Kids</h3>
</article>
In a sentence
- “The highlighted card is event-card--featured, which in BEM reads "the featured version of event-card".”
- “Using BEM, the title inside the event card got the class event-card__title.”
Level: Journeyman · More CSS terms at this level
Updated