Answer the question
In order to leave comments, you need to log in
Header naming and BEM styling?
Good day, I have a question.
Let's say there is a simple html structure from an article, inside of which there are several sections with their own headings. Usually I write it like this:
<article class="article">
<h1 class="article__title">Заголовок h1</h1>
<section class="section">
<h2 class="section__title">Заголовок секции h2</h2>
</section>
</article>
@mixin h1 {
...
}
.article__h1 {
@include h1;
}
<article class="article">
<h1 class="h1 article__title">Заголовок h1</h1>
<section class="section">
<h2 class="h2 section__title">Заголовок секции h2</h2>
</section>
</article>
Answer the question
In order to leave comments, you need to log in
Well, it really makes sense to make headings and other frequently used elements separate classes. Using mixins is bad because they duplicate the code in the final css file. As for improving reuse - it seems like it's obvious. If you need a title, you can insert it into any block. Even the article__title name is optional for them if you need to customize or set indents - this is done in a cascade
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question