Answer the question
In order to leave comments, you need to log in
How to make section distinction BEM literate?
Hello!
On the site I'm building, the background of every even-numbered section is grey. How to compose them so that it is competent in BEM?
Should each section, in addition to its direct name, be given an additional block name that will be common to all?
For example:
<header class="header section"></header>
<main>
<section class="about section"></section>
<section class="skills section"></section>
<section class="portfolio section"></section>
</main>
<footer class="footer section"></footer>
section:nth-child(2n) {
background-color: hsl(0, 0%, 96%);
}
header {}
about {}
skills {}
portfolio {}
footer {}
Answer the question
In order to leave comments, you need to log in
Well, if it’s for BEM, then in this case I see no reason to do section:nth-child(2n) like this, it increases the specificity that should be avoided., you can just mix the block with a class that will paint the necessary blocks. At any time, you may need to add some more block, which, for example, should be white after white, and then what? But if there is a separate class, for example, you can make it so that you can set the color of any block through the admin panel ..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question