W3C home > Mailing lists > Public > www-style@w3.org > June 2001

Specificity with id selectors

From: Eric Costello <eric@schwa.com>
Date: Fri, 15 Jun 2001 13:05:06 -0500
To: <www-style@w3.org>
Message-ID: <NEELIJPJGLONEACJAECIMEPDIGAA.eric@schwa.com>
Consider the following selectors:

	div#myID

and

	#myID

It is my understanding that by the rules of specificity, the former rule can
be said to have greater specificity. Is that correct, even though there
cannot legally exist more than one element with the same id attribute?

In my tests, browsers ignore a rule with the #myID selector if a rule for
div#myID also exists anywhere in the document.

TIA,
Eric

P.S. Thanks to everyone who responded to my off-topic question regarding
important declarations. For those of you that were worried, I'm not trying
to usurp user style sheets! I'm working on a book and just wanted to get my
facts straight.
Received on Friday, 15 June 2001 14:07:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:09 GMT