W
W
wakenbyWork2022-02-21 12:42:30
HTML
wakenbyWork, 2022-02-21 12:42:30

Is it possible to write like this in bem?

<div class="header">
  <div class="header__left"></div>
  
  <div class="header__right right-lite">
    <div class="right-lite__control"></div>
    <div class="header__btn"></div>
  </div>
</div>


A fictional example, I just don’t understand whether it is possible to write elements of one block inside another, as a result, native elements and parent elements in the child block. Is it possible so?

<div class="header">
  <div class="container">
    <div class="header__logo"></div>
    <nav class="header__nav"></nav>
  </div>
</div>


And this is a real example, so it is important to know is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2022-02-21
@wakenbyWork

In general, everything seems to be legal (except for semantics :-) ).
But it depends on how you write styles further.
https://ru.bem.info/methodology/key-concepts/#%D0%...
https://en.bem.info/forum/4/
that is, header__btnit should not depend on right-lite.
header__right- about positioning inside the header, should not be related to - a vivid example of a classic bam mix. That is, in fact, you need a block , but for positioning inside the header, you mix it as an elementright-lite
<div class="header__right right-lite">right-liteheader__right

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question