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

BEM Methodology

BEM Methodology

The basics, main principles, use BEM with Sass, use BEM with JS, pros and cons of BEM methodology

Jacek Spławski

January 17, 2016
Tweet

More Decks by Jacek Spławski

Other Decks in Programming

Transcript

  1. Blocks can be nested and interact with each other, semantically

    they remain equal; there is no precedence or hierarchy.
  2. Block names may consist of lowercase Latin letters, digits, and

    dashes. Individual words within names are separated by a dash. .block
  3. Block name should identify block and say what it is

    responsible for. The block name replaces IDs.
  4. Element is parts of a block and have no standalone

    meaning. They are semantically tied to its block.
  5. Element names may consist of Latin letters, digits, dashes and

    underscores. CSS class is formed as block name plus two underscores plus element name. .block__element
  6. Modifier names may consist of Latin letters, digits, dashes and

    underscores. CSS class is formed as block’s or element’s name plus two dashes. .block__element——modifier
  7. Sass — BEM .block { &——modifier {} &__element {} }

    = .block {} .block——modifier {} .block__element {}
  8. no dependencies on other elements reduce cascading problems reduce amount

    of CSS code create ready blocks library simple and understandable structure in CSS and HTML code Sass loves BEM drop tag names and IDs
  9. long class names which could look’s weird develop the habit

    to properly name class modular thinking