views:

27

answers:

2

So say we you have a CSS property that is not inherited by default. We'll call it "foo" and its default value is "black". Then we make the following html.

<div id="div1" style="foo: red;">
 <div id="div2">
   <div id="div3" style="foo: inherit;">
   </div>
 </div>
</div>

Since this property does not inherit by default, you'd think that in div2, "foo" must be "black" - the default value because it does not inherit by default.

But ... in div3 should the value for "foo" inherit "black" from its parent that did not inherit foo, or should it inherit "red" from its grandparent because its parent did not specify foo?

I need to know because I'm trying to implement something exactly to the spec.

+3  A: 

It inherits its parent's (not grandparent's) computed value: http://www.w3.org/TR/CSS2/cascade.html

ChrisW
Thanks for the reference to the spec!
Chris
+2  A: 

div3 will inherit from div2, so its foo will be black. inheritance is from the parent.

x1a4