Answer the question
In order to leave comments, you need to log in
Is it correct to do the first and last element of the list according to BEM?
Hello! Tell me, for example, I need to style the first and last element of the list. I'm trying to typeset according to BEM, I haven't used this methodology before.
Is it logical to do these elements according to the rules, does it seem to me heaped up or is it normal?:
<ul class="top-menu__list">
<li class="top-menu__item"><a href="" class="top-menu__link top-menu__link_first">Homepage</a></li>
<li class="top-menu__item"><a href="" class="top-menu__link">Style Demo</a></li>
<li class="top-menu__item"><a href="" class="top-menu__link top-menu__link_last">Link Text</a></li>
</ul>
Answer the question
In order to leave comments, you need to log in
Not so, it is more logical to hang a modifier on the item element, and not link - because the link has only one parent and does not know anything about what is happening outside.
Although it seems to me that this is the rare case when even with bam it is quite appropriate to use first-child/last-child selectors. Well, because such a modifier cannot appear somewhere in the middle and more than once.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question