The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS. Its goal is to help developers better understand the relationship between the HTML and CSS in a given project.
Standalone entity that is meaningful on its own.
Examples: header, container, menu, checkbox, input
A part of a block that has no standalone meaning and is semantically tied to its block.
A flag on a block or element. Use them to change appearance or behavior.
Here’s an example:
See the Pen BEM 101 by Divya (@DivyaPatel) on CodePen.
Modularity: Block styles are never dependent on other elements on a page, so you will never experience problems from cascading.
Reusability: Composing independent blocks in different ways, and reusing them intelligently, reduces the amount of CSS code that you will have to maintain.
Structure: BEM methodology gives your CSS code a solid structure that remains simple and easy to understand.