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

BEM - A simple CSS methodology

BEM - A simple CSS methodology

A short introduction to the BEM methodology for writing CSS.

Matheus Richard

March 19, 2020
Tweet

More Decks by Matheus Richard

Other Decks in Programming

Transcript

  1. Web History • Everything was designed to share documents •

    CSS had a different intention • Web apps became a thing
  2. Element A part of a block that has no standalone

    meaning and is semantically tied to its block
  3. Element An element CSS class is formed as block name

    plus two underscores plus element name
  4. Element An element CSS class is formed as block name

    plus two underscores plus element name
  5. Element An element CSS class is formed as block name

    plus two underscores plus element name
  6. Modifier A flag on a block or element. Use them

    to change appearance or behavior.
  7. Modularity • Block styles are independent. No cascading problems. •

    You also get the ability to transfer blocks from your finished projects to new ones.
  8. Reusability • Composing independent blocks in different ways, and reusing

    them intelligently, reduces the amount of CSS code that you will have to maintain. • You can build a library of blocks.
  9. Structure • BEM methodology gives your CSS code a solid

    structure that remains simple and easy to understand.
  10. Easy • Only three core elements • No 3rd-party library

    needed • You can start applying it now