Re: Cascading, Inheritance, and Precedence

 Eric A. Meyer <>

>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.

H1 will be red. In this case Rule 1 applies and hence the search is ended.

>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.

H1 will still be red. As I understand it, Rule 5 says: "if there are two
conflicting declarations the one specified later wins. In other words:

h1 {color: red}
h1 {color: blue}

H1 will be blue


Received on Friday, 19 September 1997 13:16:40 UTC