A
A
Anonymous Penguin2022-04-12 22:43:54
Layout
Anonymous Penguin, 2022-04-12 22:43:54

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 {}

Layout
6255e46b700f5771684938.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pershin, 2022-04-13
@Anopeng

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 question

Ask a Question

731 491 924 answers to any question