Re: [CSS21] selector's specificity issues.

Andrew Fedoniouk wrote:

> #1 -----------------------------------------------------------------
> 
> Algortihm described in [1] for counting style selector's specificity
> does not distinguish cases:
> 
> "ul li" and "ul>li"
> 
> Obviously second case is more strong/specific therefore it should have a
> bigger weight.

   No, they have the same specificity.  Where in the spec does it say 
otherwise?  The only reason "ul>li" would override "ul li" is if it 
comes later in the cascade.  Try this following test case:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<title>CSS Test: Specificty of Child vs Descendant Combinators</title>
       <style type="text/css"><!--/*--><![CDATA[/*><!--*/
		div#test1 p { color: red; }
		div#test1>p { color: green; }

		div#test2>p { color: red; }
		div#test2 p { color: green; }
       /*]]>*/--></style>

</head>

<body>
<div id="test1">
	<p>Test 1: Descendant Combinator before Child Combinator</p>
</div>

<div id="test2">
	<p>Test 2: Child Combinator before Descendant Combinator</p>
</div>
</body>
</html>

   Both should produce green text.  I tested in Firefox and IE, and got 
the expected results: Firefox passed, IE Failed miserably.

-- 
Lachlan Hunt

lachlan.hunt@lachy.id.au
http://www.lachy.id.au/

Received on Thursday, 8 July 2004 01:42:06 UTC