First-descendant-of-type selector?

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 > 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)
ul li:not(li li) wouldn't even work if it were valid, because of the case
     <ul><li><ul><foo><li> (the list we're looking at is inside another list)
ul#id li:not(ul#id li li) seems like it would work if it were valid, but it's
     NOT valid, and it's a pain to write and requires the id to be present in the

Note that this isn't entirely academic, as there's been talk in the WHATWG about 
  allowing <ins>, <del>, <fieldset>, and perhaps others that would make sense 
there. It almost certainly won't happen for HTML5 since it wouldn't be backwards 
compatible parsing-wise, but there's no reason another the XHTML version of 
HTML5 couldn't have it (since XML parsing rules would require it to work as 
expected), or some other markup language could allow a similar construct.


Received on Wednesday, 30 August 2006 20:23:59 UTC