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"
<html xmlns="" xml:lang="en" lang="en">

	<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; }


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

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

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

Lachlan Hunt

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