Nesting a ul inside an ol

rlavoir picture rlavoir · Sep 8, 2016 · Viewed 13.9k times · Source

Im trying to make an ordered list with two items, and three items under each list, which have bullet points. my code is not passing validation because it saysElement ul not allowed as child of element ol in this context. But everywhere I look it says this is ok. here is my code

<ol>
    <li>First numbered Item</li>
        <ul>
            <li>one thing</li>
            <li>two things</li>
            <li>three things</li>
        </ul>
    <li>Second numbered Item</li>
        <ul>
            <li>one thing</li>
            <li>two things</li>
            <li>Three things</li>
        </ul>
</ol>

not sure what im doing wrong. thanks for the help, first post here :)

Answer

Mick picture Mick · Sep 8, 2016

The children of lists should be list items. You have both list items and unordered lists as children of your ordered list. You need something like:

<ol>
    <li>
        <p>First numbered Item</p>
        <ul>
            <li>one thing</li>
            <li>two things</li>
            <li>three things</li>
        </ul>
    </li>
    <li>
        <p>Second numbered Item</p>
        <ul>
            <li>one thing</li>
            <li>two things</li>
            <li>Three things</li>
        </ul>
    </li>
</ol>