Setting class in stylesheet instead of markup

I'm trying to apply my poor CSS knowledge to a little toy project I have, and it annoys me endlessly that I have to declare column widths in my HTML markup.

Is there a way that I could instead

<div class="grid_4"></div>

      

use something like

<div id="leftNav"></div>

      

and in your stylesheet apply the grid_4 class to the element with id leftNav?

In my opinion, it will look something like this.

#leftNav {
    apply-class: grid_4;
}

      

Is there anything similar in CSS?

+3


source to share


1 answer


Not in regular CSS, no.



However, there are CSS preprocessors that create a new minilanguage, which is then processed into regular CSS, which adds these and other features. See less , Sass .

+2


source







All Articles