- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Fri, 8 Jan 2010 12:49:09 -0600
- To: Brad Kemper <brad.kemper@gmail.com>
- Cc: Nikita Popov <privat@ni-po.com>, www-style list <www-style@w3.org>
On Fri, Jan 8, 2010 at 12:40 PM, Brad Kemper <brad.kemper@gmail.com> wrote:
>
> On Jan 8, 2010, at 10:25 AM, Tab Atkins Jr. wrote:
>
>> On Fri, Jan 8, 2010 at 12:19 PM, Nikita Popov <privat@ni-po.com> wrote:
>>> I have yet another question about the exact syntax of the pseudo-class:
>>> Could I for example use this rule
>>> .page form:any(> input, label select)
>>> to match all input elements, that are direct descendants of forms or selects
>>> what are contained in a label?
>>> (At least it would make sense, if allowing the attribute selectors in
>>> :any())
>>
>> Hmm, that's interesting. You want a space between the form and :any,
>> since this isn't a pseudoclass for the form. (That is, you're not
>> trying to match the form.)
>
> See?It's not just me.
It may not just be you, but it's still a consistent rule throughout
all of CSS. ^_^
>> It's still just syntax sugar for ".page form > input, .page form label
>> select",
>
> Wouldn't making it a pseudo-class mean that the specificity of the rule might be different (in general; I didn't calculate for this particular example)? If so, that is more than just syntax sugar.
This is true.
>> so I don't see any technical problems with it. I don't know
>> if we want to allow a naked combinator at the front like that, though.
>> You could avoid that with:
>>
>> .page form :any(form > input, label select) {}
>
> Yeah, unless the "form" part was important (due to an id, for instance):
>
> .page form :any(form#myform > input, form#myform label select) {}
>
> That's back to repeating, so you'd want to be able to do it the other way:
>
> .page form#myform :any(> input, label select)
Worst case you could do it as:
.page form#myform :any(form#myform > input, label select)
The fact that the label is a descendant of the form in question is
already communicated through the other part. But hey, a little bit of
repeating like that won't kill anyone anyway.
Also, I just remembered that this was originally introduced as
:matches(), which might make some usages more clear than my :any()
name.
~TJ
Received on Friday, 8 January 2010 18:49:37 UTC