Re: selector negation (was: Re: New version of the Selectors module of CSS3)

Bjoern Hoehrmann wrote
> * "Jonas Sicking" <sicking@bigfoot.com> wrote:
> | I'd guess that the WG has recogniced the need for class inversion since
the
> | CSS3 drafts has contained inversion of some of the classes. What I'm
asking
> | for is to make inversion generic on *all* pseudo classes by saying "any
> | pseudoclass can be inverted by putting not- infront of it" rather then
> | adding some specific classes that are inverted. That way it could also
be
> | possible to have the CSS parser handle the inversion and thus making css
> | renderers a bit slimmer.
>
> I really don't like a 'not-' prefix as a generic modifier.
> What about a suffix pseudo-class?
>
>   p:contains("foo"):not
>
>   "selects element p not containing 'foo'"
>
>   a[href^='http://www.w3.org']:not
>
>   "selects element a with href not starting with 'http://www.w3.org'"
>
>   p:subject > a:not
>
>   "selects element p with no child 'a'"
>
>   h1:subject + p:not
>
>   "selects element h1 with no adjacent sibling p"
>
>   a:hover:not

> I think it makes small sense to say for negating attribute selectors you
use
> this syntax for negating pseudo-classes use that syntax, for negating type
> selectors use again another syntax.

I completly agree that the "not-" syntax is not perfect. However the :not
pseudoclass looks even stranger to me. Think of a selector like

a[href='http://www.w3.org']:not:contains('foobar'):not
and
a[href='http://www.w3.org']:not[class~='standard']:hover:not

that gives really messy syntax.
The coder in me wants to use ! for all inversions

a[href!='http://www.w3.org']:!contains('foobar')
and
a[href!='http://www.w3.org'][class~='standard']:!hover

but the designer-friendly-guy in me likes the not- syntax better.

I think it will be hard to find a good common syntax for attributes,
pseudoclasses and elements because they have different syntax in CSS. If
they don't share a "match syntax" why should they share a "don't match"
syntax.

/ Jonas Sicking

Received on Monday, 9 October 2000 17:42:17 UTC