W3C home > Mailing lists > Public > www-style@w3.org > February 2003

Re: comments on Selectors

From: Peter S. Linss <peter@linss.com>
Date: Mon, 17 Feb 2003 22:00:15 -0800
Message-ID: <3E51CBEF.3030303@linss.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: Brant Langer Gurganus <brantgurganus2001@cherokeescouting.org>, W3C Style List <www-style@w3.org>

Boris Zbarsky wrote:

>>Its been a while since I read it and who knows how up-to-date the 
>>document is.
>>    
>>
>
>It's up to date.  All it says is that a rule like:
>
>*:empty { color: red }
>
>will take longer to process than a rule like
>
>.empty-stuff { color: red }
>
>because the former will be compared to all elements.
>

Again, note the difference in the selectors.

*:empty
is functionally (and performance) equivalent to
:empty

.empty-stuff
is functionally (and performance) equivalent to
*.empty-stuff

There is no performance difference (in Mozilla) for having an implied or 
explicit * portion of a selector.

>
>The perf difference is hard (if possible) to notice on a typical web page; that
>document's primary audience are people writing Mozilla themes and XBL (the
>amount of CSS in a typical Mozilla theme plus the default CSS that's always
>applied to the chrome is easily 10 times larger than the amount of CSS I've
>seen in any web page...)
>
Agreed, also note that the performance hit really comes from having a 
large number of rules where the final selector has no type, class or ID 
component (because each of those rules is then be tested against every 
node in the DOM tree).
Received on Tuesday, 18 February 2003 01:01:19 GMT

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