D
D
Denis Sopko2019-05-09 21:22:55
BEM
Denis Sopko, 2019-05-09 21:22:55

Is it possible to create two classes in the BEM methodology?

There are three blocks with different classes

<div class="header-top__language">
<div class="header-top__contact">
<div class="header-top__profile">

For all of them, I need to set some of the same properties. What would be the right way to do it? Group classes and write styles or add a second class that will be the same in all blocks (these classes that are already there, I need them)?
And is it even possible to make two classes for an element in the BEM methodology?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Pershin, 2019-05-09
@denisopko

In your case, I would advise adding a second class (Yes, it is possible and necessary) for example header-top__item and describe the general properties in it:

<div class="header-top__language header-top__item">
<div class="header-top__contact header-top__item">
<div class="header-top__profile header-top__item">

In this case, you can not only create 2 classes, but make a mix of blocks and elements, which will later allow them to be reused:
<div class="header-top__item language header-top__language"></div>
<div class="header-top__item contact header-top__contact"></div>
<div class="header-top__item profile header-top__profile"></div>

As a result:
header-top__item - Describes a number of elements with similar properties
language , contact , profile - Independent blocks
header-top__language , header-top__contact , header-top__profile - Modifiers in the context of header-top (Not the best header-top name but the question is not in that)

R
rogiivs, 2019-05-09
@rogiivs

just add another class and that's it, don't worry. This is fine

S
sim3x, 2019-05-09
@sim3x

sass +@extend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question