The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS how to inherit from nonparent element Reply To: how to inherit from nonparent element


So I’d like to say something like “p.example {inherit-from: h1; font-size: n}”. Is there any way to write CSS for this case?

Not with CSS…although a pre-processor might help.

What I have found is that when defining styles for headings it’s also useful to create a class for them at the same time.


h1, .h1 {

That way I have a reusable class which I can use on any element to mimic an h1 and maintaining my semantics.

In fact, Chris linked this the other day.