Re: First-descendant-of-type selector?

----- Original Message ----- 
From: "Bjoern Hoehrmann" <derhoermi@gmx.net>
To: "dolphinling" <lists@dolphinling.net>
Cc: "W3C CSS List" <www-style@w3.org>
Sent: Wednesday, August 30, 2006 2:04 PM
Subject: Re: First-descendant-of-type selector?


|
| * 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.
| -- 

If :not will be relaxed to contain not only simple selectors
then selector

ul li:not(li li) will allow to match "nearest child of a type" case.

Needed it in practical design or not is another question.
Let's assume that this is nice to have feature.

Say selector like
X Y:not(X > Y)
naturally complements "X Y" and "X>Y" selectors.

There are use cases of CSS selectors where this is a desirable feature.

Think about element.getElementBySelector() implementation.
CSS cascading just meaningless in this environment.


Andrew Fedoniouk.
http://terrainformatica.com 

Received on Thursday, 31 August 2006 18:21:08 UTC