htmlcssbem

Block inside elements BEM-methodology


Depending on the documentation of BEM you should not use Elements within elements.

That makes sense to me, because a block contains elements which cannot be outside that block. But can an elements contain a block? So that the block inside that element cannot be outside that element.

The official Website of BEM uses this. But I always thought the idea of blocks is, that you can put it anywhere on the page without any dependencies.

Here is the DOM from the official Website enter image description here


Solution

  • Actually BEM allows elements inside elements.

    And of course BEM allows blocks inside elements but not in the way they can't also be used outside that element.

    Feel free to keep blocks inside or outside elements. It's just ok.