Use duplicate class name for element?

I found that there are many frameworks out there that will check for a duplicate class name before adding a new class name to the element, which I think will slow down performance.

Are there any problems if the element has a double class name?

It will also apply the CSS class without conflicts while using the name of the duplicate class.

<div class="aa bb cc aa"></div>

      

Is it possible to add a class name just like elem.className += ' ' + 'aa ee'

, even an element has a duplicate class name?

+3


source to share


2 answers


There is nothing "wrong" with a duplicate class name, it is simply redundant. Probably a small performance impact, but it will really make a big difference if you have a lot of duplication.



Also, avoiding duplicates just helps keep things in order.

+5


source


Semantic interface makes heavy use of attribute selectors

like here



.ui.grid [class*="left floated"].column {
  margin-right: auto;
}
.ui.grid [class*="right floated"].column {
  margin-left: auto;
}

      

If you want margin-left

and margin-right

have auto value

, you must have a duplicate of the class, floated

(for example <div class="left floated right floated">Lorem</div>

)

0


source







All Articles