Answer the question
In order to leave comments, you need to log in
How to style such html in BEM style?
Greetings to all, connoisseurs! Can you please clarify this question for me. Let's say we have html
<a href="#" class="block">
<span class="block__element">span</span>
<span class="block__element2">span2</span>
</a>
.block:hover .block__element{
color: green;
}
.block:hover .block__element2{
color: red;
}
Answer the question
In order to leave comments, you need to log in
I don’t see anything criminal in doing a cascade in this case.
If I'm not mistaken, BEM is about minimizing the cascade, not completely eliminating it.
Especially if from all BEM you use only the naming convention and general principles.
After all, BEM is not Holy Scripture, but simply a methodology, a tool that no one forbids to customize for themselves.
That is how it is done.
It's a view selector block(mod) element
, it doesn't go beyond BEM.
(For example .block--left .block__element
) The
pseudo-class is just a modifier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question