My Take on OOCSS, SMACSS and BEM
If you're familiar with CSS and Sass, you've likely come across different approaches people take to write their class names.
Here's an approach I've been using that's been working well for me.
BEM (block, element, modifier) is a widely adopted front-end naming methodology.
Commonly BEM uses double dashes and double underscores. The reason being, you can then use single dashes as well, whilst double distinguish the differences between the block, element or modifier. Here's an example:
Standard 'BEM' way
1 | // Component |
My BEM Approach
Especially with the last example, I find it hard to process when scanning quickly. Here's how I do things. I use camelCase for my block, element and modifiers, then use a single underscore or dash to split things up:
1 | // Component |
Read on to learn how I name CSS classes using consistent naming conventions.
Browse by category:
- apple1
- bash1
- browser1
- case study4
- chrome2
- chrome dev tools4
- clojure overtone2
- conference2
- css2
- dev tips1
- digihike1
- dotfiles2
- event4
- ffconf1
- freelance6
- gaming2
- health3
- hexo1
- https1
- jank1
- javascript1
- jobs1
- lego1
- mcrfred107
- nux1
- octopress4
- photography2
- raspberry pi1
- responsive web design1
- sass1
- screencast1
- speaking2
- svg4
- unplugged6
- upfrontconf1
- web development2
- webgl1
- wordpress17
- work51
- workflow16