ACTIVITY #20: Research BEM - Block, Element, Modifier - Architecture

ACTIVITY #20: Research BEM - Block, Element, Modifier - Architecture

  • What is BEM?:

    • BEM is a popular naming convention used in CSS to organize code in a modular and reusable way.

    • It stands for:

      • Block: A standalone entity like a button or menu (.button).

      • Element: A part of the block that has a specific function (.button__icon).

      • Modifier: A variation of the block or element (.button--primary).

  • Advantages of BEM:

    • Improves code readability.

    • Encourages modularity, making it easy to manage large projects.

    • Helps avoid CSS conflicts.

  • Practice:

    • Create an HTML structure using BEM naming conventions and write CSS to style it.

      CSS (styles.css)

      Here's the Output

Explanation:

BEM Structure: The class names follow the BEM convention, where:

Block: Represents a high-level component (e.g., header, main, section, footer).

Element: A part of a block that performs a specific function (e.g., header__title, nav__item, section__title).

Modifier: A variant of a block or element that changes its appearance or behavior (e.g., section--primary, service--highlighted).