- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Thu, 14 Jan 2010 07:51:16 -0600
- To: Alan Gresley <alan@css-class.com>
- Cc: Niels Matthijs <niels.matthijs@internetarchitects.be>, Boris Zbarsky <bzbarsky@mit.edu>, www-style list <www-style@w3.org>
On Thu, Jan 14, 2010 at 6:41 AM, Alan Gresley <alan@css-class.com> wrote: > So you are saying that you want to match the first descendant of a > particular element in the DOM. This could be done like first-child and would > be a structural pseudo-class. Yeah, that's what's desired, but note that multiple elements can match here. For example, in the following code: <article> <section> <h1>foo</h1> <p>bar bar bar</p> <section>baz</section> </section> <div class=special> <section>qux</section> </div> </article> A selector like "article % section" should match both the first child of article, and the section inside of the div. It wouldn't match the section containing "baz", though, since that has another section ancestor between it and its closest article ancestor. > .focusBlock header:first-descendant { > // style rules // > } > > > In theory you could also have last-descendant. > > > .focusBlock header:last-descendant { > // style rules // > } :last-descendant would actually be marginally easier to implement, if I'm thinking correctly, and plenty useful on its own (for many of the same reasons that jQuery's closest() method is so useful). ~TJ
Received on Thursday, 14 January 2010 13:52:12 UTC