W3C home > Mailing lists > Public > www-validator@w3.org > April 2010

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

From: Paul Novitski <paul@juniperwebcraft.com>
Date: Thu, 01 Apr 2010 10:15:45 -0700
To: <www-validator@w3.org>
Message-Id: <E1NxNzS-0002p4-PR@cl25.gs01.gridserver.com>

>On 1 Apr 2010, at 08:07, Hanno van Dijk - Novisites wrote:
>>Using the following code:
>>                         <a href='nl/content/home'><li><br />Home</li></a>
>>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)

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



Paul Novitski
Juniper Webcraft Ltd.
Received on Thursday, 1 April 2010 17:16:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:59:17 UTC