A
A
Andrei Popov2019-04-04 15:51:51
BEM
Andrei Popov, 2019-04-04 15:51:51

Dependency of an element on the implementation of a child element, is it acceptable according to BEM?

<div class="content">
       <div class="content__text-block">
          <div class="content__head">Крупный текст</div>
          <div class="content__desc">обычный текст</div>
        </div>
</div>

.content
   &__text-block
      font-size: 1.2rem
   &__head
      font-size: 2em
   &__desc
      font-size: 1em

Is it correct according to BEM if the font size of an element depends on the implementation of the parent element?
Or is it necessary to make the text-block element a block in such cases?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Prisyazhnyuk, 2019-04-04
@andrei500

Well, firstly, you need to work on the semantics in html. Team div-yank is not cool at all.
Here are two implementation options:
1)

<section class="content">
  <div class="content__text-wrap">
    <h2 class="content__title">Заголовок</h2>
    <p class="content__descr">Блок с текстом</p>
  </div>
</section>

2)
<section class="content">
  <div class="content__text-wrap article">
    <h2 class="article__title">Заголовок</h2>
    <p class="article__descr">Блок с текстом</p>
  </div>
</section>

And about the font size: there is not much difference, it all depends on the context. Don't forget modifiers. You can type this way and that and awry.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question