Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a class of classes in HTML?

Tags:

html

css

With my list of html style class continues to grow, like:

<button type="button" class="btn btn-default btn-sm ...">
</button>

I wonder whether there is an easier way to represent this list, like:

.list_of_css = "btn"+ "btn btn-default"+"btn-sm"+...

So I can simply use:

<button type="button" class="list_of_css">
</button>
like image 592
Tianyun Ling Avatar asked Sep 28 '22 05:09

Tianyun Ling


1 Answers

I recommend using a CSS pre-processor as suggested by j08691. I specifically recommend using Sass.

Sass inheritance example:

.fancy-button{
  @extend .btn, .btn-default, .btn-sm;
}

HTML as expected:

<button type="button" class="fancy-button">Fancy Button</button>

References:

Sass: http://sass-lang.com/

Sass Inheritance: http://sass-lang.com/guide#topic-7

What Nobody Told You About Sass’s @extend: http://www.sitepoint.com/sass-extend-nobody-told-you/

like image 165
pygeek Avatar answered Nov 02 '22 05:11

pygeek