CSS is organized using the widely used BEM (Block Element Modifier) technique, which divides the code into reusable blocks, components inside those blocks, and modifiers to change the styles.
This approach minimizes class name clashes, maintains readability, and keeps the CSS modular.
Code
/* BEM Methodology Example */ /* Block: Menu */ .menu { list-style-type: none; margin: 0; padding: 0; } /* Element: Item */ .menu__item { margin-bottom: 10px; } /* Modifier: Active */ .menu__item--active { background-color: #007BFF; color: white; } |
The menu class is represented in this example as a block, menu__item as an element inside the block, and menu__item--active as a modifier for items that are now active.
This facilitates simple style management for various stages and clarifies the application locations of each style.
CSS is organized using the widely used BEM (Block Element Modifier) technique, which divides the code into reusable blocks, components inside those blocks, and modifiers to change the styles.
This approach minimizes class name clashes, maintains readability, and keeps the CSS modular.
Code
/* BEM Methodology Example */ /* Block: Menu */ .menu { list-style-type: none; margin: 0; padding: 0; } /* Element: Item */ .menu__item { margin-bottom: 10px; } /* Modifier: Active */ .menu__item--active { background-color: #007BFF; color: white; } |
The menu class is represented in this example as a block, menu__item as an element inside the block, and menu__item--active as a modifier for items that are now active.
This facilitates simple style management for various stages and clarifies the application locations of each style.
Copyrights © 2024 letsupdateskills All rights reserved