P
P
pacman1232018-10-25 15:25:55
Layout
pacman123, 2018-10-25 15:25:55

How to combine nesting and BEM?

Hello! The question is more general.
In layout, I try to adhere to the BEM methodology.
The main goal of this methodology is the reuse of blocks.
So. In a number (most, if we are talking about landing pages) cases, it is more convenient for me not to assign unique classes to elements at all, but simply to refer to them through nesting. That is, these are elements that are entered once and are not reused.
The question is - is it allowed to use BEM in relation to several elements within the framework of one project, and where there is no such need - simple nesting? Isn't this bad practice?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Pershin, 2018-10-25
@pacman123

Only allowed if there are no other options. That's the whole point of BEM, the fact that nesting seems like a good idea to you now will limit you in the future when reusing, modifying and maintaining the project. To be honest, I can’t imagine a situation where nesting can be more convenient than naming.

M
Maria Korobkogolovykh, 2018-10-25
@Rikazavr

It always seemed to me that nesting is a taboo in the BEM ideology. I try to avoid it, assigning a class to an element is not so burdensome. But I allow myself to use selectors like :not(:last-child), nth-child, because sometimes you can’t do without them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question