3

Here is my HTML

<ul class="menu">
  <li class="menu__item">
    <a href="" class="menu__link"></a>
  </li>
  <li class="menu__item">
    <ul class="list"> // can I place this block inside here?
      <li class="list__item">
        ...
      </li>
      <li class="list__item">
        ...
      </li>
    </ul>
  </li>
</ul>

In this case, I place the block list inside the element menu__item.

I wonder, is this legal?

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Yokiijay
  • 711
  • 2
  • 7
  • 18
  • If you want this naming scheem for `ul class="list"`, then the list should be a standalone component that can be used in many places without the parent wrappers. – Danyal Imran May 09 '19 at 06:30
  • I think it is OK to use block inside block as long as your parent block doesn't have any say on styles inside the child block – AvcS May 09 '19 at 06:45

2 Answers2

2

Yes, it is valid. See example from section Nested Lists in - https://html.com/lists/.

random
  • 7,756
  • 3
  • 19
  • 25
2

As per this documentation from BEM, we can nest the blocks. I.e. a block can have another block in it. The only condition is that the children blocks should be independent on the parent.

https://en.bem.info/methodology/block-modification/#placing-a-block-inside-another-block

Ishwar Patil
  • 1,671
  • 3
  • 11
  • 19