Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Writing Clean and Maintainable Code with BEM CSS

Avatar for Axel Andrian Axel Andrian
December 23, 2018

Writing Clean and Maintainable Code with BEM CSS

Avatar for Axel Andrian

Axel Andrian

December 23, 2018

More Decks by Axel Andrian

Other Decks in Programming

Transcript

  1. What is BEM? BEM — Block Element Modifier is a methodology that

    helps you to create reusable components and code sharing in front-end development
  2. B E M BLOCK ELEMENT MODIFIER Standalone entity that is

    meaningful on its own. 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. Header Container Navbar Card Header Title Navbar Item Card Title Disabled Size Color
  3. Write the CSS Examples : head img {} -> Don’t

    do this with BEM #header {} -> Don’t use ID avoid this : .header .header__title .header__title--red {}