Inheritance query CSS

Discussion in 'Web Design and Development' started by andyjamesnelson, Sep 7, 2008.

  1. andyjamesnelson macrumors 6502

    Joined:
    Aug 24, 2003
    Location:
    Jacob's house
    #1
    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
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  3. andyjamesnelson thread starter macrumors 6502

    Joined:
    Aug 24, 2003
    Location:
    Jacob's house
    #3
    I know some things are inherited by default. It when to and why to use the :inherit property that escapes me. Andy
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    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.
     

Share This Page