W3C home > Mailing lists > Public > www-style@w3.org > July 2004

Re: [CSS21] selector's specificity issues.

From: Lachlan Hunt <lachlan.hunt@iinet.net.au>
Date: Thu, 08 Jul 2004 15:39:59 +1000
Message-ID: <40ECDE2F.4050608@iinet.net.au>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: www-style@w3.org

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="http://www.w3.org/1999/xhtml" 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

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:13:06 UTC