验证错误:ul不允许作为元素跨度的子元素 [英] Validation error: ul not allowed as child of element span

查看:404
本文介绍了验证错误:ul不允许作为元素跨度的子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么WC3验证器将此HTML标记为无效,它报告的错误是...

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.)''

我正在使用HTML5,此代码用于面包屑。

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>


推荐答案

< span> 根据定义是内联元素(例如,你在段落中使用它),而< ul> 是一个块元素(这是它自己的一小块空间,通常在它之前/之后有空格,不像< span> )。

<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>).

其他人们遇到了同样的问题,最后使用< div> 代码。请参阅是否可以将列表放入span tag?

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?

这篇关于验证错误:ul不允许作为元素跨度的子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆