V
V
Vlad2020-11-17 21:54:54
css
Vlad, 2020-11-17 21:54:54

Is it allowed, according to the BEM methodology, not to assign BEM classes to some tags inside the layout, but to leave elements without classes at all?

Is it allowed, according to the BEM methodology, within the BEM layout not to assign BEM classes to some tags, but to leave elements without classes at all?

Example:

<ul class="menu__links">
   <li><a class="menu__link" href="#about">О нас</a></li>
   <li><a class="menu__link" href="#portfolio">Наши работы</a></li>
   ...
</ul>


Or the tag must also be assigned a class, although in fact I don’t need it in FIG.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mletov, 2020-11-17
@mletov

Well, if you think logically: the element has a purpose, and since there is a purpose, there must be a class that describes this purpose. And if there is no assignment, then "what the hell is not needed" is not the class, but the element itself
https://ru.bem.info/methodology/solved-problems/

I
Ivan V, 2020-11-18
@verkhoturov

Of course, I'm not a "CSS tag curator", but according to BEM it is allowed for tags to have no classes.
Why do I think so?
1) The documentation does not say anywhere that each tag inside the block must have a class.
2) In the BEM context, "tag" !== "element".
For example, if there is an "element" containing text content, there is no point in giving a class to a tag , and even to a tag if its appearance suits you. 3) Yandex itself (the creator of BEM) quietly leaves tags without classes. An example on this page https://yandex.ru/dev/maps/mapsapi/ If you look at the code, you can see that paragraphs, links, lists, "highlighted" text do not have classes. If the creators themselves do this, then you can too :) <strong><p>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question