Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

andyjamesnelson

macrumors 6502
Original poster
Aug 24, 2003
286
0
Jacob's house
Hey something that troubling me is the :inherit property within css.

I understand that say:


<div id="introduction">
<p>hdsfghhdgkhkhgkhgkhdkhdghkdhkdhgkhgk</p>
<p>lfjlfjljfljdlfjzldjldjg'lzj'jjdljglzjglkjg'ldjg'ldjg''g</p>
</div>

.

Then the <p> elements are children (descendants) of the <div> etc. In fact I get everything about Inheritance I think apart from why on earth the :inherit is at all useful?

I mean if you apply a style to the <div> all its descendants will 'inherit' that style as long as there isn't a conflicting style rule etc.

So when would I ever need to use the :inherit property? because descendants already inherit - and if there is no style rule for an elements ancestor then what could the element :inherit as such?

I am sure there is something subtle I must be not understanding here?

Andy
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
I know some things are inherited by default. It when to and why to use the :inherit property that escapes me. Andy

The first link I provided provides a list of CSS properties that have inherit set by default. Using inherit (when it's not default) simply allows you to take advantage of the cascading effects of CSS so if you have to change a property, you won't have to change all of its descendants (that don't inherit by default). It's not a part of CSS I use very often, but some people have a use for it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.