W3C home > Mailing lists > Public > www-style@w3.org > August 2006

Re: First-descendant-of-type selector?

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Wed, 30 Aug 2006 23:04:50 +0200
To: dolphinling <lists@dolphinling.net>
Cc: W3C CSS List <www-style@w3.org>
Message-ID: <dptbf25ro6kl6ht6v2291b07iipfll53fl@hive.bjoern.hoehrmann.de>

* dolphinling wrote:
>Suppose HTML were extended so that <li> had to be a descendant of <ul>, but not
>necessarily a child: there could be another element (or multiple elements)
>between them. Is there any way to reliably select the <li>(s) in that case?

ul *:not(ul) > li { ... } /* or ...:not(ul):not(ol)... */

>ul > li {}; obviously doesn't work, since li isn't the child.
>ul li {}; doesn't work, because of the case <ul><foo><li><ul><li>
>     (there's another list inside the one we're looking at)

I assume that your selector only fails to meet your requirements because
it selects the li in the inner list even though it is a child of the ul
element. If that is not the problem, and you only want to look at outer
lists, then this is impossible to achieve using CSS Selectors. Also note
that there is generally no need to select the specific list items in one
step, you could just combine

  ul * li { ... }
  ul > li { ... }

or whatever you are really trying to achieve. If you need something more
sophisticated, you should use a real selection language like XPath.
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Wednesday, 30 August 2006 21:04:55 UTC

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