D
D
DemonCyborg2019-10-23 10:00:50
css
DemonCyborg, 2019-10-23 10:00:50

Is it correct to have a nested element with class input_label-text in input_label?

There is an input block:

<div class='input'>
  <label class='input__label'>
     <span class='input__label-text'>Label text</span>
     <input class='input__control'>
  </label>
</div

I recently started learning/using BEM. I can not understand whether this naming of element classes is correct? According to BEM, you can't create element elements, but a class called input_label-text is more like an element element, although it is not input_label_text. Is this class naming correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marty McFly, 2019-10-23
@DemonCyborg

Yes, that's possible.

input__label-text is more like element element,
No, it doesn't look like it, separating the class name with a dash is quite normal practice.
Only, of course, input_label-text is not an element of the input_label element, but the same as it is an element of the input block

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question