Validation error: ul is not allowed as a child span

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

'' The ul element is not permitted as a child span in this context. (Suppression of further errors from this subtree.) ''

I am using HTML5 and this code is for crackers.

<span class="bread"> <ul> <li><a href="./index.php">HOME</a></li> <li>ABOUT</li> </ul> </span> 
+4
source share
5 answers

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

Other people had the same problem, and <div> tags were used instead. See Is it possible to place a list inside a span tag?

+4
source

Following the html5 guidelines, the <span> element can only contain phrasing-content . The <ul> element is not in the list of content tag phrases. The html validation engine enforces these rules.

You can use a <div> instead.

+3
source

if you create a div as "display: inline", it should nominally conform to the rule, while it behaves exactly the same as span :)

+2
source

If you use it as a wand, it is a navigation element, so <nav> makes the most sense as the container of your <ul> . Otherwise, give the UL class "breadcrumb" <ul class="breadcrumb"> and create it based on its class.

+1
source

USE <div>

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

instead of <span>

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

All Articles