Harvard Extension School
CSCI E-12 Fundamentals of Web Site Development | Fall 2019

## Nested Lists - li is a child of ul!

Keep in mind that the only allowed child of a `ul` element is an `li` element. So in a nested list, the nested `ul` needs to contained within the `li`:

Correct | Incorrect ul must be within li
--- | ---
Example in Gist View Example Validate Example
    <ul>
    <li>Tea
        <ul>
            <li>Kenyan</li>
            <li>Sikkim</li>
            <li>Ceylon</li>
            <li>Assam</li>
            <li>Oolong</li>
        </ul>
    </li>
    <li>Potato Chips
        <ul>
            <li>Dirty&apos;s</li>
            <li>Art&apos;s and Mary&apos;s</li>
            <li>Tim&apos;s Cascade</li>
            <li>Cape Cod</li>
        </ul>
    </li>
    </ul>
| Example in Gist View Example Validate Example
    <ul>
    <li>Tea</li>
        <ul>
            <li>Kenyan</li>
            <li>Sikkim</li>
            <li>Ceylon</li>
            <li>Assam</li>
            <li>Oolong</li>
        </ul>

    <li>Potato Chips</li>
        <ul>
            <li>Dirty&apos;s</li>
            <li>Art&apos;s and Mary&apos;s</li>
            <li>Tim&apos;s Cascade</li>
            <li>Cape Cod</li>
        </ul>
    </ul>

Sometimes this is confusing, since in the "HTML" form of HTML5, the end tags are options for `li`, so while it may appear that you can have a `ul` as a child of `ul`, you really can't -- there's an implied end-tag there.

Correct HTML serialization | Correct XML serialization
--- | ---
Example in Gist View Example Validate Example
    <ul>
    <li>Tea
        <ul>
            <li>Kenyan
            <li>Sikkim
            <li>Ceylon
            <li>Assam
            <li>Oolong
        </ul>

    <li>Potato Chips
        <ul>
            <li>Dirty&apos;s
            <li>Art&apos;s and Mary&apos;s
            <li>Tim&apos;s Cascade
            <li>Cape Cod
        </ul>

    </ul>
| Example in Gist View Example Validate Example
    <ul>
    <li>Tea
        <ul>
            <li>Kenyan</li>
            <li>Sikkim</li>
            <li>Ceylon</li>
            <li>Assam</li>
            <li>Oolong</li>
        </ul>
    </li>
    <li>Potato Chips
        <ul>
            <li>Dirty&apos;s</li>
            <li>Art&apos;s and Mary&apos;s</li>
            <li>Tim&apos;s Cascade</li>
            <li>Cape Cod</li>
        </ul>
    </li>
    </ul>

Copyright © David Heitmeyer