DEV Community

Discussion on: Why BEM?

 
kwiat1990 profile image
Mateusz Kwiatkowski

It's up to you what you decide but as long as nested elements are part of your block element, you should use block__element pattern.

If you start to have problems with this flat structure, it is a good sign that you should start a new block - you can use block inside another block:

form.form
  label.form__label
  input.form__input
  button.button
    span.button__label
Enter fullscreen mode Exit fullscreen mode

For clarity in this example I omitted most of the markup, so you can see the HTML structure and BEM structure.

Thread Thread
 
bonstine profile image
Bonnie Simon

Oh okay I got it now! I one block isn't enough, you create another block inside it. Thanks man.✨