Skip to content

Instantly share code, notes, and snippets.

@amabes
Created December 11, 2019 09:23
Show Gist options
  • Save amabes/6e0035d44e999cbdad958ffc6364b924 to your computer and use it in GitHub Desktop.
Save amabes/6e0035d44e999cbdad958ffc6364b924 to your computer and use it in GitHub Desktop.
OOCSS and BEM (airbnb)

OOCSS and BEM

We encourage some combination of OOCSS and BEM for these reasons:

  • It helps create clear, strict relationships between CSS and HTML
  • It helps us create reusable, composable components
  • It allows for less nesting and lower specificity
  • It helps in building scalable stylesheets

OOCSS, or “Object Oriented CSS”, is an approach for writing CSS that encourages you to think about your stylesheets as a collection of “objects”: reusable, repeatable snippets that can be used independently throughout a website.

BEM, or “Block-Element-Modifier”, is a naming convention for classes in HTML and CSS. It was originally developed by Yandex with large codebases and scalability in mind, and can serve as a solid set of guidelines for implementing OOCSS.

We recommend a variant of BEM with PascalCased “blocks”, which works particularly well when combined with components (e.g. React). Underscores and dashes are still used for modifiers and children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment