- From: Douglas Rand <drand@sgi.com>
- Date: Thu, 18 Sep 1997 14:10:52 -0400
- To: Andi Hindle <andih@harlequin.co.uk>
- CC: www-style@w3.org
Andi Hindle wrote: > > Hi > > I'm trying to figure out what takes precedence over what in a stylesheet. > Thus, given: > > body { > > color : #FFFFFF; > } > > h1 { > > color : #FF0000; > } > > will my <h1> turn out red or white? Apologies for the basic question, but > I can't find anything that tells me the answer and my browser experiments > have been inconclusive -- I'd like to know what's _meant_ to happen, even > if it doesn't actually happen yet in some implementations! ;-) It should turn out red AFAIK. As to why, that's more difficult. The body color is inherited by h1, but is overridden by the specific rule for h1. The reason it isn't clear is that the spec. doesn't ever seem to make what is (to me) an obvious limitation on rule matching. That is that the leaf node specified in the selector (in this case just the single element) must be a match for the element being looked up. All other desirable behaviors are defined by inheritence of properties. The limitation can only be inferred, since I don't believe it's stated (or wasn't, but I'm sure some enterprising person will dig it up to contradict me. I confess to having done an imperfect job of reading the spec). If that limitation isn't true, then the inheritence model makes no sense since H1 will have to be "white" and not "red" since it matches at the same precedence and is earlier in the ordering (which gives it greater force). Similarly all such rules would match and override child elements. Doug -- Doug Rand drand@sgi.com Silicon Graphics/SSO http://reality.sgi.com/drand Disclaimer: These are my views, SGI's views are in 3D
Received on Thursday, 18 September 1997 14:16:23 UTC