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

RE: [css3] "Selectors that People Actually Use"

From: Alan Gresley <alan1@azzurum.com>
Date: Tue, 19 Feb 2008 19:10:44 -0700
To: fantasai <fantasai.lists@inkedblade.net>
cc: Boris Zbarsky <bzbarsky@MIT.EDU>, Daniel Glazman <daniel.glazman@disruptive-innovations.com>, www-style@w3.org
Message-ID: <20080219191044.34b83c2f3c9bef00757a2c62c0fb7450.c691dde42c.wbe@email.secureserver.net>

fantasai wrote:

> Alan Gresley wrote:
> > Boris Zbarsky wrote:
> > 
> >>> p[class*=""], p:not([class*=""]) {}
> >> That's equivalent to the selector "p".
> >>
> >> -Boris
> > 
> > Correct but which is of greater specificity?
> > 
> > 
> > div {width: 100px;height:100px;background:red}
> > div[id*=""], div:not([id*=""]) {background:blue}
> 
> The second selector has greater specificity.
> (Probably it would be shorter to write
>    div[id], div:not([id])
> )
> 
> ~fantasai


It would be shorter still if we just had.

div[id]

since Gecko handles that quite ok. :-)


Anyway div:not([id]) and div:not([id*=""]) are treated different in particular circumstances when using universal selectors and chained selectors.

http://css-class.com/test/css/selectors/not-attribute-variable1.htm


Sarafi 3 and Opera 9.5 passes each test. Gecko 1.9 fails each test.


You could also have a string of selectors.

div.x, dix.y {} /* legacy style */
div[id="x"] {} /* x special style */
div[id="y"] {} /* y special style */
div[id*=""], div:not([id*=""]) {} /* progressive enhancement general style */


Alan

http://css-class.com/
Received on Wednesday, 20 February 2008 02:11:01 GMT

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