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

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 UTC