[thelist] css rendering myths and optimizing

Hardacker, Andrew Andrew.Hardacker at Compuware.com
Wed Mar 13 11:53:00 CST 2002


<snip>
p.highlight {color:#f00}
p {color:#000;}

then all of the paragraphs will be black, including those using
class="highlight", as that is the "last" colour declaration.

</snip>

Well, not really. The "highlight" class will appear highlighted. In this
example, the relative specificity of the selector is used, not sequence. "p"
has a specificity of 1 while "p.highlight" has a specificity of 11. So
p.highlight rules.

That's the theory at least. Various browser implementations seem to
interpret this differently.

http://www.htmlhelp.com/reference/css/structure.html info on calculating
specificity
http://www.people.fas.harvard.edu/~dbaron/css/test/sec060403b an contrarian
view

Andy Hardacker
http://hardacker.com




More information about the thelist mailing list