Course contentsShow
← Web Development
Lesson 1320 of 2,98224. CSS Architecture and MaintainabilityFree lesson

BEM Fundamentals: Block, Element, Modifier

Learning the three core concepts of BEM and how they map to component structure.

BEM Fundamentals: Block, Element, Modifier

You'll learn the three building blocks of BEM naming and how each one maps to your HTML structure.

BEM is a naming convention that helps you write organized, predictable CSS class names. It stands for Block, Element, Modifier — three distinct parts that work together to describe your component structure in a self-documenting way.

The Three Core Concepts

Block is a standalone component that makes sense on its own. Think of it as the container or "thing" itself — like a button, a card, a menu, or a search form. Blocks are independent and reusable.

Element is a part of a block that doesn't make sense outside that block's context. Elements are the pieces inside the block — like the title inside a card, the icon inside a button, or the input field inside a search form. Elements depend on their parent block.

Modifier represents a different state, variation, or version of either a block or element. Modifiers answer questions like "which kind?" or "what state?" — like a disabled button, a large card, or an active menu item.

How They Map to Components

Imagine building a card component:

  • The Block is the card itself
  • Elements are the card's title, image, and description
  • Modifiers might be "featured card" or "card with shadow"

Each piece has a specific role. The block stands alone. Elements live inside and serve the block. Modifiers change appearance or behavior without creating entirely new components.

This structure mirrors how you naturally think about interface components — as independent pieces with internal parts that can appear in different variations.

Key Takeaway: BEM gives you three clear naming roles — Block (independent component), Element (dependent part), and Modifier (variation) — that directly reflect your component's structure and make CSS class names predictable and meaningful.