liveBook · Manning

BEM

As explained in Tiny CSS Projects

BEM is a component-based CSS architecture that organizes interfaces into blocks, elements, and modifiers.

BEM is a component-based CSS architecture that organizes an interface into independent, reusable blocks, their elements, and modifiers. It gives component classes a consistent naming pattern that helps scope styles and prevent collisions. section 11.1.3 section 11.4

Build a BEM class name from three roles:

Animated share component

Name the wrapper share, its menu share__menu, and its open state share_expanded. CSS can hide the menu by default, then reveal it with .share_expanded .share__menu when JavaScript toggles the modifier after a click. section 11.6.2

How Tiny CSS Projects covers it

How deep it goes
Defines blocks, elements, and modifiers, then applies them to an interactive share component without treating BEM as a complete CSS system.
Examples
Uses a social-media share component with share, share__menu, share__button, and share_expanded classes.
What it assumes
Starts from HTML and CSS, while using JavaScript only to toggle the component's expanded state.
What you can do after
Apply BEM to name and style reusable interface components with explicit structural and state-related classes.
How it connects
Compares BEM with OOCSS and SMACSS, and connects it to components, CSS scoping, JavaScript state, and transitions.

Also explained in

Compare how 2 books explain BEM →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.