Validation error: ul not allowed as child of element span

user2177629 picture user2177629 · Apr 5, 2013 · Viewed 16k times · Source

I do not understand why the WC3 validator is flagging this HTML as invalid, the error it reports back is...

''Element ul not allowed as child of element span in this context. (Suppressing further errors from this subtree.)''

I'm using HTML5, and this code is for breadcrumbs.

<span class="bread">
    <ul>
        <li><a href="./index.php">HOME</a></li>
        <li>ABOUT</li>
    </ul>
</span>

Answer

Stephen Fischer picture Stephen Fischer · Apr 5, 2013

<span> by definition is an inline element (so you use it inside a paragraph, for example), while <ul> is a block element (which is its own little chunk of space, usually with space before/after it unlike <span>).

Other people have had the same issue, and end up using <div> tags instead. See Is it possible to put a list inside a span tag?