S
S
Senseich2019-04-24 01:44:20
Layout
Senseich, 2019-04-24 01:44:20

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

1 answer(s)
D
dom1n1k, 2019-04-24
@Senseich

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 question

Ask a Question

731 491 924 answers to any question