W3C home > Mailing lists > Public > www-style@w3.org > March 2009

Re: [css-3 selectors] The :parent pseudo-class

From: Giovanni Campagna <scampa.giovanni@gmail.com>
Date: Tue, 24 Mar 2009 14:05:26 +0100
Message-ID: <65307430903240605ge9e23f4ma0bc2756ff9deeb1@mail.gmail.com>
To: Gabriele Romanato <gabriele.romanato@gmail.com>
Cc: "www-style@w3.org" <www-style@w3.org>
This was already proposed, in the form of "h3:matches(# > a)"
(:matches pseudo-class) or "$h3 > a" (changing subject in the
selector). Both were rejected because they have high implementation
costs.

I'm not sure what implementors will say, but I don't think they will like it.

Giovanni

(anyway, this is a Level 4 feature)

2009/3/24 Gabriele Romanato <gabriele.romanato@gmail.com>:
> CSS is a language that uses a top-down approach when walking the DOM tree.
> Sometimes, however, it's useful to walk the tree from bottom to top.
> Consider the following:
>
> <h3><a href="#"></a></h3>
>
> h3 {
> padding-bottom: 0.2em;
> }
>
> I want to reset the bottom padding only on h3 elements that have a link
> inside.
> Authors usually use classes in such cases. With the :parent pseudo-class,
> instead, we could write:
>
> a:parent {
> padding-bottom: 0;
> }
>
> The :parent pseudo-class, whose syntax is E:parent, matches the parent
> element of a given child
> element. This is the same as Node.parentNode in a DOM context.
>
> HTH
>
>
> http://www.css-zibaldone.com
> http://www.css-zibaldone.com/test/  (English)
> http://www.css-zibaldone.com/articles/  (English)
> http://mimicry.css-zibaldone.com/ (Blog)
> http://www.flickr.com/photos/gabrieleromanato/ (Flickr)
>
>
>
>
>
>
Received on Tuesday, 24 March 2009 13:06:06 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:17 GMT