Allow UL/OL as direct children of UL/OL?

View: New views
2 Messages — Rating Filter:   Alert me  

Parent Message unknown Allow UL/OL as direct children of UL/OL?

by rokahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The HTML 5 draft and preceding w3c standards seem to specify that <ul>/<ol> can not be direct child of <ul>/<ol>.  Specifically, the content model of <ol> and <ul> is "Zero or more li elements."  This poses a problem for designing a rich text editor (which we're doing).  Typically, when users add a list item onto an already created list, it is encoded as a separate list rather than joining it with previous list items.  Consider a case where a user of a rich text editor such as Google Mail or Google Documents starts with "apple" & "banana" at level 1 and "pear" at level 2 as shown below:
  * apple
    * pear
  * banana
When the user indents "banana", it's coded as a separate <UL> as shown below.

> <ul>
>   <li>apple</li>
>   <ul>
>     <li>pear</li>
>    </ul>
>   <ul>
>     <li>banana</li>
>   </ul>
> </ul>

Consider what happens now when the user attempts to further indent "banana" to look like the following:
>  * apple
>     * pear
>      * banana
This could be coded correctly but that would require the editor to automatically join pear and banana into a single <UL>.  Since "banana" was previously coded as a separate UL, indenting it instead produces the following code where a UL which is a direct child of a UL as shown below:

> <ul>

>   <li>apple</li>
>   <ul>
>     <li>pear</li>
>   </ul>
>   <ul>
>     <ul>
>       <li>banana</li>
>     </ul>
>   </ul>
> </ul>

This is correctly rendered on all the browsers I cared to check (FF2, IE7, & Opera).  Is there some compelling reason to continue strictly specifying that UL or OL may not be directly contained in a <UL>/<OL>?  If not, considering Google's using it and all the browsers support it, perhaps the specification ought to be changed.

Re: Allow UL/OL as direct children of UL/OL?

by Lachlan Hunt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Rocky Kahn wrote:

> The HTML 5 draft and preceding w3c
> standards<http://www.w3.org/html/wg/html5/#the-ol>seem to specify that
> <ul>/<ol> can not be direct child of <ul>/<ol>.
> Specifically, the content model of <ol> and <ul> is "Zero or more
> li<http://www.w3.org/html/wg/html5/#li>elements."  This poses a
> problem for designing a rich text editor (which
> we're doing).  Typically, when users add a list item onto an already created
> list, it is encoded as a separate list rather than joining it with previous
> list items.  Consider a case where a user of a rich text editor such as
> Google Mail or Google Documents starts with "apple" & "banana" at level 1
> and "pear" at level 2 as shown below:
>   * apple
>     * pear
>   * banana
> When the user indents "banana", it's coded as a separate <UL> as shown
> below.
>> <ul>
>>   <li>apple</li>
>>   <ul>
>>     <li>pear</li>
>>    </ul>
>>   <ul>
>>     <li>banana</li>
>>   </ul>
>> </ul>

This is a problem with the editor, not with HTML.  To do nested lists,
the sub-lists need to be put within an <li> element of the parent list.

<ul>
   <li>apple
     <ul>
       <li>pear</li>
     </ul>
   </li>
   <li>banana</li>
</ul>

--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

LightInTheBox - Buy quality products at wholesale price!