Cascading, Inheritance, and Precedence

Eric A. Meyer writes:

 >    This brings me to my question.  Given the CSS rules...
 >      h1 {color : #FF0000;}
 >      body {color : #FFFFFF;}
 > ...NOW what color will H1 text be?  Under my previous reasoning, it should
 > be white, because the BODY rule comes after the H1 rule.  This just seems
 > wrong, though.
 >    Then I figured it out-- I think.  The answer seems to be in Cascade Rule
 > 1, which states:
 >     "Find all declarations that apply to the element/property in question.
 >      Declarations apply if the selector matches the element in question.
 >      If no declarations apply, the inherited value is used."
 > Since there are H1 rules which do apply, those rules override any inherited
 > property values.
 >    However, this is only the case if Cascade Rules with lower numbers have
 > higher precedence-- something which the specification does not define.
 > Does Rule 1 have more weight than Rule 5?  If so, the problem is solved.
 > If not... well, ick.

The specification states that "To find the value for an
element/property combination, the following algorithm must be
followed", then five numbered steps are described. This is another
way of saying that a lower number rule has higher precedence than a
higher number rule.

So, yes, the problem is solved. 



H      k   o   n      W   i   u   m       L   i   e
World     W      i     d     e       Web  Consortium

Received on Friday, 19 September 1997 16:45:54 UTC