[whatwg] Nested list

Adrian Sutton adrian.sutton at ephox.com
Mon Jul 13 08:58:49 PDT 2009


On 13/07/2009 16:45, "Erik Vorhes" <erik at textivism.com> wrote:
> Part of the reason that browsers handle this--
> <ul>
>     <li></li>
>     <ol><li></li></ol>
>     <li></li>
> </ul>
> -- pretty well is because, in HTML 4.01 (and earlier HTML specs), <li>
> was not required to be explicitly closed, so it would implicitly
> handle that <ol> as a child of the preceding <li>. (Inconsistencies in
> rendering most likely arise because the browser havs already found the
> explicit close to a list item before getting to the nested list.)

Actually, at least Safari and FireFox treat the invalidly nested OL as a
completely separate item - ie: they don't treat it as a child of the
previous LI.

You can see this quite clearly if you apply a style to the LI (or just look
at the resulting DOM):
<ol>
<li style="font-weight: bold; ">Item 1
  <ol><li>Nested</li></ol>
</li>
</ol>

<ol>
<li style="font-weight: bold;">Item 1</li>
<ol><li>Nested</li></ol>
</ol>

The first list is entirely bold, the second on "Nested" is not bold which
matches the DOM structure that Safari shows.

> Do you have use case for when a child list is *not* an item in the
> parent list? Otherwise, it doesn't make sense *not* to wrap the child
> list in the <li> element.

This is the real crux of why I think browser behavior is wrong - in every
case I've seen, the author intends the indent to mean a sub-point, not a new
point which for some reason is indented further. Given the rendering readers
would expect an indented list item to be a sub-point as well.

I don't see that HTML 5 has any choice but to define the current browser
rendering and DOM structure as the way things are - changing the resulting
DOM structure would break backwards compatibility. However, I'd really like
to see browsers change to create correctly nested lists so the list
structure actual matches the author intent. I'm somewhat doubtful browser
vendors would want to change though and I must admit it does potentially
create compatibility problems for existing JavaScript editors which would
have to be explored more.

Regards,

Adrian Sutton. 
______________________
Adrian Sutton, CTO
UK: +44 1 628 200 182 x481  US: +1 (650) 292 9659 x717
Ephox <http://www.ephox.com/>
Ephox Blogs <http://planet.ephox.com/>, Personal Blog
<http://www.symphonious.net/>




More information about the whatwg mailing list