Skip to content
GabineteTools for thinking

No. 0239Workflow and delivery

BEM (Block, Element, Modifier)

Yandex · 2009

Wooden board: tangled pieces of paper on the left; on the right, tiles with pieces tied to themselves, one moved and a cobalt twin.

The table / Model card · No. 0239 · Workflow and delivery

BEM (Block, Element, Modifier)

CSS naming convention that organises interface code into independent blocks, their elements and modifiers.

The essentials

What it is

What it solves

How can many developers write CSS for a large interface without naming collisions and style leaks?

When to use it

Large front-end codebases with several contributors. Design systems with reusable components. Projects without CSS-in-JS or scoped styles.

Where it comes from

BEM emerged inside Yandex from 2006 work on Yandex.Music and Ya.Ru; the independent-block layout was presented at ClientSide'07 (Moscow, fall 2007); Lego 2.0 in March 2009 is described by Yandex as the start of BEM; Yandex went open source on GitHub in 2010.

Yandex · 2009

How it works

Every interface part is a block that stands alone. Parts that only make sense inside a block are elements, named block__element. Variations in look or state are modifiers, named block--modifier. Because each class name states what it belongs to, selectors stay flat and low in specificity, and a block can be moved without breaking styles elsewhere.

You need

A component inventory or design system and a team agreement on the naming format.

You get

A consistent set of class names and a flat stylesheet organised by block.

Case

Illustrative case

Orchard Bank's web team has three squads editing one stylesheet and keeps breaking each other's buttons. They adopt BEM. The card component becomes block 'card', with elements 'card__title' and 'card__action', and a modifier 'card--highlighted' for promoted offers. A lint rule rejects selectors that nest more than one class deep. After the rewrite of the account page, a design change to the highlighted card touches one file and no other page changes. Code review comments about unexpected style bleed drop noticeably in the following sprint.

A fictional company used to explain the model.

Caution

When to avoid it

  • Small one-off pages.
  • Frameworks that already scope styles per component, where BEM adds verbosity without benefit.

Common mistakes

  • Nesting elements inside elements (block__a__b).
  • Using modifiers without the base class.
  • Creating blocks that depend on their position in the page.
  • Mixing BEM with unrelated naming styles.

Known weaknesses

  • Long class names inflate markup.
  • Relies on discipline since the browser enforces nothing.
  • Overhead in projects that already scope CSS.
  • Debate on how to name states and nested parts.

How to apply it in 5 steps

How to apply it

BEM (Block, Element, Modifier)

5 steps

Use the arrow keys to move between steps, Home and End for the first and last, and Enter to fold or unfold the booklet.

View all 5 steps
  1. Identify blocks

    List the independent components of the interface.

  2. Name elements

    Name each part inside a block as block__element.

  3. Add modifiers

    Express variants and states as block--modifier or block__element--modifier.

  4. Keep selectors flat

    Style by single class and avoid nesting on tags or ids.

  5. Enforce

    Add linting and code review checks for the convention.

Which decisions it helps with

Decision profile

A tool to take action on a product or service.

Keyboard: Tab to the sheet, use the arrows to explore the assessments and their questions, and press Escape to close the note.

IIdentity

Type of tool
Other formatDoes not fit neatly into the available categories
Decision stage
Plan the work, roles and deadlinesalso: generate ideas or options (33 %)
What it applies to
A product or service
Discipline
Agile and software development

IIIResources required

  • TimeWeeks or months
  • PeopleSeveral teams
  • DataA few readily available facts
  • ExpertiseAnyone who has read a page of instructions
  • Time horizonOne to three years
  • ScopeBetween “a unit or department” and “the whole organization”
  • FrequencyOccasionally
The team’s own knowledge is enough

IITen axes

The dot shows which end the model favours. A hollow dot means no clear preference.

  • DirectionExecution
  • Top-downBottom-up
  • PeopleProcesses
  • Generate optionsNarrow down options
  • Step-by-step analysisIntuition and experience
  • A strict sequence of stepsA flexible framework
  • Protect what we haveTake a risk
  • Improve what we havemixedFundamental change
  • Inside the organisationOutside the organisation
  • Understand firstmixedAct now

IVUseful when

Applicable traits

  • How it supports actionDecide what comes first
  • Product stageGrowing an existing product
How was this profile calculated?

An automated system reads each model card and answers the same questions for every model. This profile has answers for 77 of 77. No answers are entered by hand.

A very high probability counts as “yes” and a very low one as “no”. Intermediate answers are hidden.

On the axes, mixed means the model favours neither end.

How it works →

Thinking space

Workflow and delivery

They organize and accelerate day-to-day delivery: Kanban, DevOps, development cycles, automation and work standards.

Membership: 17 % · also “Product discovery and validation” (14 %)

View in the atlas of spaces →

Each point is a model. Distance reflects answers to the decision questions. Light points share this model’s space.

Similar models

Verified sources

Use the arrow keys to move between sources.

Original work

  1. Yandex (n.d.). BEM history (Methodology > History). bem.info.Yandex's own timeline: blocks concept from 2006-07, Lego 2.0 in March 2009 marks the start of BEM, open-sourced on GitHub in 2010.View source: BEM history (Methodology > History) (opens in a new tab) ↗

Key development

  1. Yandex (n.d.). BEM Quick Start. bem.info.Official definitions of block, element and modifier.View source: BEM Quick Start (opens in a new tab) ↗

Critique

  1. Wathan, A. (2017). CSS Utility Classes and "Separation of Concerns". adamwathan.me.Objects that BEM-style component classes tied to content force you either to duplicate styles between similar components or to give up the separation of concerns the naming was meant to protect.View source: CSS Utility Classes and "Separation of Concerns" (opens in a new tab) ↗

Wikipedia article (opens in a new tab) ↗