W3C home > Mailing lists > Public > www-style@w3.org > April 2007

Re: Select a parrent node with s CSS selector?

From: James Craig <jcraig@apple.com>
Date: Tue, 24 Apr 2007 12:26:07 -0700
Message-Id: <8C33BEB6-26BD-4D81-B9E4-24B5EC3F37C2@apple.com>
To: www-style@w3.org

Kang-min Liu wrote:

> Rather then use "<" to select parent element, I find it more sane  
> to use
> some special sort of mark the one you want in the search path of a  
> selection.
> I'd propose using a pair of () as the real target of a selector:
>    body>div.content (a:link) > p.description
> The overhead of this implementation may just be one more variable  
> to hold
> the target.

You meant this, right?

	body > div.content (p.description) > a:link

This idea was proposed a few years ago. I can't remember why it was  
dismissed or forgotten. I like the simplicity, but it may have had  
something to do with the use of :not(), :lang(), and other  
parenthetical patterns as selectors. Here is another option following  
that convention, :ancestor( anotherSelector ). What do you think?

If selecting the paragraph in:

	div.content p.description a:link


	div.content p.description a:link:ancestor(div.content  
p.description) /* more specific */

Somewhat verbose, but an established practice of limiting the  
ancestor path would make it much easier to parse. Therefore, it could  
be a "recommended coding practice" to always

Other options that would be harder to parse but effectively do the  
same thing once calculated:

	div.content p.description a:link:ancestor(p)

Of course, it opens the floodgate to crazy selectors though...

a.selected:ancestor(li):not([title="eatin ur foodz"])

Received on Tuesday, 24 April 2007 19:49:55 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:28 UTC