Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing CSS within CSS

Tags:

css

Is there a way to define a CSS class as being equal to another? For example if I had a class:

.myClass{
    background-color: blue;
}

is there a way to define a second class as having the same style as myClass without just copying and pasting?

EDIT:

Sorry, let me be a bit more clear. Is it possible to do this after declaring the first class, possibly even in another stylesheet?

like image 620
geekchic Avatar asked Dec 09 '25 10:12

geekchic


1 Answers

Yes, like this:

.myClass,
.mySecondClass,
.myThirdClass {
    background-color: blue;
}

EDIT:

Based on your edit: What you might be looking for, if this is something you really want to do is to look into SASS which basically is like css but with variables and stuffs. But vanilla CSS doesn't have any native support for what you want.

like image 126
Fredrik Avatar answered Dec 12 '25 09:12

Fredrik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!