X
X
x3miSt2020-04-11 12:27:56
BEM
x3miSt, 2020-04-11 12:27:56

Is it possible to shorten classes in BEM?

Let's say I have a block with the class:

"advantages"

Can I set the class to the elements in the block in an abbreviated form, but in the BEM style "adv__title" ?

.advantages { background: #000; }

.adv__title { color: #fff; }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ReActor Dmitry Vershansky, 2020-04-11
@x3miSt

Greetings!
It is not desirable for two reasons:
a) This method (abbreviations), only at first glance seems to be directed towards minimizing the time spent on layout. In fact, at the same time, you increase the chances of an error when transferring classes to css, as selectors + to this, spend time thinking - "How can I reduce it all the same? One way or another ..."
b) When using plugins, for the purpose of autoexpanding selector class structures, working, for example, with preprocessors (SASS / SCSS), you prevent them from working correctly, from the point of view of the BEM context.
Conclusion:
It is much less expensive to copy-paste the name of an already created block for subsequent elements and their modifiers than to think about abbreviations every time. And also in preprocessors, the need to copy-paste generally comes to naught, since the name of the block can be replaced with the symbol - & (ampersand)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question