Re: Using <a> in a <ul> element in front of <li>

>On 1 Apr 2010, at 08:07, Hanno van Dijk - Novisites wrote:
>
>>Using the following code:
>>
>><ul>
>>
>>                         <a href='nl/content/home'><li><br />Home</li></a>
>>
>></ul>
>>
>>Is this a known issue or a coding flaw, because it works as it 
>>should and looks okay to me!
>
>At 4/1/2010 06:20 AM, David Dorward wrote:
>The only element that may be a child element of a <ul> is <li>, and 
>a <li> element may not be a child element of an <a> element.


Hanno, check the spec:

HTML 4.01 Specification
10 Lists
10.2 Unordered lists (UL), ordered lists (OL), and list items (LI)
http://www.w3.org/TR/html4/struct/lists.html#h-10.2

The rule is:

         <!ELEMENT UL - - (LI)+                 -- unordered list -->

This says that the UL element must have both start and end tags and 
it must contain one or more LI elements as its direct descendants and 
no others.

In contrast, the LI element is defined by:

         <!ELEMENT LI - O (%flow;)*             -- list item -->

where 'flow' is defined as either block-like or inline elements.

         <!ENTITY % flow "%block; | %inline;">

So the ancestry UL > LI > A is valid HTML 4.01 but UL > A > LI is not.


Conveniently, the UL/LI structure is frequently used as an example in 
the documentation on how to read the DTD:

3 On SGML and HTML
3.3 How to read the HTML DTD
3.3.3 Element declarations
http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.3

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 

Received on Thursday, 1 April 2010 17:16:12 UTC