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

BEM Block Naming

Defining independent, reusable components as blocks with clear, semantic names.

BEM Block Naming

You'll learn how to name BEM blocks as independent, reusable components with clear, semantic names.

What Is a BEM Block?

In BEM (Block, Element, Modifier), a block is a standalone, reusable component that can exist on its own anywhere on your page. Think of blocks as LEGO pieces—each one is complete and independent. The name you give a block should describe what it is, not what it looks like or where it lives.

Blocks Answer "What Is It?"

A block name should be a noun that clearly identifies the component's purpose:

  • card — a content card
  • nav — navigation component
  • search-form — a search form
  • site-header — the site's header

Notice these names are generic enough to be reused but specific enough to be meaningful. They describe function, not appearance or location.

What Makes a Good Block Name

Use lowercase and hyphens for multi-word names (also called kebab-case):

  • ✅ user-profile
  • ❌ userProfile or user_profile

Avoid presentational names that describe how it looks:

  • ❌ blue-box, left-sidebar
  • ✅ alert, sidebar

Avoid location-based names that tie the block to one place:

  • ❌ header-search, footer-nav
  • ✅ search-form, nav

The goal is portability—if you renamed or moved the component, would the name still make sense?

Real-World Example

Imagine building a product card. You might call it product-card because that's what it is—not home-item (location-dependent) or white-card (appearance-dependent). Tomorrow, you could use product-card on a search results page or even style it blue—the name still makes perfect sense.

Key Takeaway: Name BEM blocks with clear, semantic nouns that describe the component's purpose, not its appearance or location, ensuring they remain reusable across your entire site.