DEV Community

Discussion on: BEM Methodology In CSS: A Quick Start Guide

Collapse
 
tomekbuszewski profile image
Tomek Buszewski

Oh boy, I still remember pitching BEM to my colleagues in 2014. How they laughed.

I really like this approach, as it introduces component thinking. It takes some time to wrap your head around it, but when it clicks, it becomes the only way you write your CSS.

The only problem I always had, was when you want to modify your block and have its children affected:

card card--dark
  card__header
  card__body

This always resulted in two ways:

  • I created a modified version of every element inside;
  • or I stacked the elements (card--dark > .card_header).

I know the first solution is "cleaner", but sometimes it was really too much. What's your take on this?