Class Inheritance

Hi Experts,

Within CSS, is it possible to inherit one class from another?

For example, if I have a general class with 10 properties that will be used on 30 controls, but for 10 of which I want exactly the same properties, but just change the text color to red. Can I do a class red that is a inherits class general then just change my color?

Thank you
APD TorontoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
You can't do inheritance but you can do overrides. Create your generic class containing the 10 properties and another class containing just the color, and then apply both classes to your element. Something like this:

.class1 { color: blue; font-size:10px; border: 1px solid green; margin: 0px; }
.class2 { color: red; }

<div class="class1 class2">This text will adopt all the properties of class1 and class2 so will be coloured Red</div>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APD TorontoSoftware DeveloperAuthor Commented:
Really?  You can have multiple classes? Cool!

Chris, can you take a look at my other 2 questions?
0
Chris StanyonWebDevCommented:
Yeah, sure. Do you want to post links to them.
0
APD TorontoSoftware DeveloperAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.