- From: Gabriele Romanato <gabriele.romanato@gmail.com>
- Date: Tue, 24 Mar 2009 03:31:03 +0100
- To: www-style@w3.org
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 02:31:45 UTC