F
F
fregire2018-03-15 18:50:08
Layout
fregire, 2018-03-15 18:50:08

How to implement HTML structure according to BEM?

Hello! I ran into a problem: is it possible to create an element in a block that centers all the content of this block? Did it this way:

<div class="page__header">
    <div class="page__wrapper">
      <header class="header">
        <div class="header__left-content">
          <div class="logo">
            <!-- Logo -->
          </div>
        </div>
        <div class="header__right-content">
          <ul class="nav">
            <!-- Li -->
          </ul>
          <div class="header__search">
            <!-- Input -->
          </div>
        </div>
      </header>
    </div>
  </div>

It would be possible to reduce the nesting if we put the header__wrapper inside the header block, but is this structure correct?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Serj-One, 2018-03-15
@fregire

Why create an element when you can create a block modifier?
<div class="header header--center"></div>

R
rusglov, 2018-03-15
@rusglov

<div class="page__wrapper">
      <header class="header page__header">
        <div class="header__left-content">
          <div class="logo">
            <!-- Logo -->
          </div>
        </div>
        <div class="header__right-content">
          <ul class="nav">
            <!-- Li -->
          </ul>
          <div class="header__search">
            <!-- Input -->
          </div>
        </div>
      </header>
    </div>
  </div>

All this can be done using mixes, and not through a modifier, because the appearance is configured through the modifier, not positioning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question