Home › Forums › CSS › how to inherit from nonparent element › Reply To: how to inherit from nonparent element
February 27, 2016 at 2:44 am
#238519
Paulie_D
Member
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.
So:
h1, .h1 {
font-size:3rem;
}
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.
http://csswizardry.com/2016/02/managing-typography-on-large-apps/