M
M
Muvka2019-05-04 09:12:31
BEM
Muvka, 2019-05-04 09:12:31

Who does BEM markup?

Hello. I keep trying to master BEM layout, but I can't find clear answers on several points. Share your experience.
1. Let's say that in 90% of the blocks, the headings have the same styles. Is it worth making a separate class for them, or is it better to write heading styles for each block separately in each block? This can be implemented with a mixin, not difficult, but is it correct? Because css is getting bigger.
2. Centerer. Same question. Should I prescribe or create a container class for each block? It's just that somewhere this centerer will be outside the block

<div class="block container">
  
</div>

And somewhere inside
<div class="block">
  <div class="block__container container">
    
  </div>
</div>

Will it be right?
3. And more. Is it possible to use global styles in body to set size, color and font? For the most frequently repeated font. Or is it better to ask separately in each block?
Maybe the questions are stupid, but I can not find the answer, but I really want to figure it out.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Glebov, 2019-05-04
@SkiperX

1)
mixins 2) .page__container
3) set .page to it, well, you can also style styles for body
. Font styles in bem are inherited and this is normal

M
McBernar, 2019-05-04
@McBernar

1. Styling H1. Semantically, this is much more correct than attaching classes to tags.
2. Don't be a hostage to methodology. If you have a modifier for different pages and different elements, it is much more convenient to take it out as a separate class. As, in general, and does most of the frameworks.
3. I ask separately, but this is my personal quirk. This makes it easier to tweak each style separately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question