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.

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reference to the spec!
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.