Is anything except LI's allowed in a UL?

According to the HTML 4 specs, the XHTML 2 specs and the HTML 5 specs that code is invalid.

HTML 4

<!ELEMENT UL - - (LI)+

This means that inside a <ul> there can only be multiple <li> elements.

XHTML

Both types of lists (ul|ol) are made up of sequences of list items defined by the li element.

HTML 5

Content model:
Zero or more li and script-supporting elements.

Note that script-supporting elements are elements that are not rendered, and currently include only <script> and <template>.


No, it is not valid. The only allowed elements inside ul are li.

Corrected sample:

<ul>
    <li>
        <span>1</span>
        <ul>    
            <li>1.1</li>
            <li>1.2</li>
            <li>1.3</li>
        </ul>
    </li>
    <li>
        <span>2</span>
        <ul>    
            <li>1.1</li>
            <li>1.2</li>
            <li>1.3</li>
        </ul>
    </li>
</ul>

Don't allow your designer to write any HTML code for you. Hire a front-end developer that really knows how to deal with HTML and XHTML.


That is indeed not valid; what was probably meant is:

<ul>
  <li>1
    <ul>
    <!-- ... -->
    </ul>
  </li>
</ul>

Also, what is your designer doing writing the HTML?

Tags:

Html