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

Re: Selector Sugar

From: François REMY <fremycompany_pub@yahoo.fr>
Date: Thu, 9 Oct 2008 19:24:38 +0200
Message-ID: <8EFA6E62177D48CB9A614A4BD62F0888@fremycompany>
To: "Brad Kemper" <brkemper.comcast@gmail.com>, "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "W3C Style List" <www-style@w3.org>

From: "Brad Kemper" <brkemper.comcast@gmail.com>
>
>
> On Oct 9, 2008, at 8:53 AM, Tab Atkins Jr. wrote:
>
>> I want to talk about two issues of syntactic sugar that I believe  would 
>> be very useful to us authors.  [..........]
>>
>> (1) Scoped selectors within a stylesheet.
>>
>>  [.........]
>>
>> (2) Multi-matching selector
>>
>>  [.........]
>>
>> ~TJ
>
> I agree that those would be valuable. [........]
>
> I wonder if it might even be possible to leave out the @scoped, and  just 
> have it like this to do the same thing:
>
> #nav-menu {
> h1 {
> //This is equivalent to the selector "#nav-menu h1",
> //and so won't target <h1>s across the rest of the page.
> ...
> }
> ul {
> ...
> }
> more rules...
> } //end of scope

I agree with you but there's a problem :

    li.hoverLink {
        a:hover,
        a:focus {
            color: red;
         }
    }

The parser will think that 'a' is a property and 'hover,' a value, and that 
the property incorectly ended.
With another syntax, like an at-rule, it should delete this problem.

    li.hoverLink {
        @rule a:hover, a:focus {
             color: red;
        }
    }

The problem with this, is that we introduce the use of at-rules in the 
selectors, and it was not existing before.
Some old browers can think we have :

    li.hoverLink {
        // bad line
        color: red;
        // bad line
    }

So, as I prefer a 'not-friendly' solution (@scope and :any) than no solution 
at all, I agree to discuss this...
Fremy 
Received on Thursday, 9 October 2008 17:25:19 GMT

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