UL标签内的标签H3 [英] Tag H3 inside UL tag

查看:64
本文介绍了UL标签内的标签H3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
UL允许使用LI吗?

我正在做类似的事情:

<ul>
    <h3><a name="titlename">Title</a></h3>
    <li>Text.</li>
    <li>More text.</li>
    <span><a href="/url">Click here</a> to go to some place.</span>
</ul>

但是我在Visual Studio中收到警告:

But i get warnings in visual studio:

Warning Validation (HTML5): Element 'h3' cannot be nested within element 'ul'.  
Warning Validation (HTML5): Element 'span' cannot be nested within element эul'.    

我用Google搜索并找到看起来有另一个标签不是问题,而是在< ul> ю

I googled and found that looks like it is not a problem to have another tags but <li> inside <ul>ю

但是无论如何,也许有人对此有任何看法.它会破坏某些东西吗?是否将< h> 标记或< ul> 内的其他任何标记放入?您对此有何经验?

But anyway may be some one have any opinions on that. Could it break something? do put you <h> tags or any another tags inside <ul>? What is your experience with that?

推荐答案

< ul> 表示无序列表,而< li> 表示列表项属于该无序列表-因此只有在< ul> 元素内包含< li> 元素才真正有意义.如果要给无序列表指定标题,请在列表的外部处添加标题(这将是更正常"的方式),或者在< li> 内列表中的元素.

<ul> denotes an unordered list, while <li> denotes a list item that belongs to that unordered list - so it only really makes sense to have <li> elements within a <ul> element. If you want to give the unordered list a title, do it outside of the list (this would be the more 'normal' way), or within an <li> element that is inside the list.

<h3>My List Title</h3>
<ul>
  <li>List items in here...</li>
</ul>

这篇关于UL标签内的标签H3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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