W3C home > Mailing lists > Public > www-style@w3.org > September 1997

Cascading, Inheritance, and Precedence

From: Eric A. Meyer <eam3@po.cwru.edu>
Date: Fri, 19 Sep 1997 11:06:22 -0500
Message-Id: <v03102804b0484f803736@[129.22.138.152]>
To: www-style@w3.org
   Okay, this latest thread has brought up an interesting question.  The
original question from Andi Hindle was, in summary:

Given the CSS rules...
     body {color : #FFFFFF;}
     h1 {color : #FF0000;}

...will H1 text be white, or red?

   I originally claimed that specificity would cause H1s to be red, and
then reversed myself, because under the weighting rules defined in Cascade
Rule 4, both statements have the same specificity.  Therefore, the tie is
broken by Rule 5, which says later declarations win out over earlier ones.
   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.

--
Eric A. Meyer  -  eam3@po.cwru.edu  -  http://www.cwru.edu/home/eam3.html
 Hypermedia Systems Manager
 Digital Media Services                http://www.cwru.edu/dms/dms.html
 Case Western Reserve University       http://www.cwru.edu/
Received on Friday, 19 September 1997 11:06:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:51 GMT