Jit*_*yas 44 css xhtml w3c accessibility
我们可以使用任何其他标记在<ul>
伴随着<li>
?
喜欢
<ul>
Some text here or <p>Some text here<p> etc
<li>item 1</li>
Some text here or <p>Some text here<p> etc
<li>item 1</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
Jon*_*nes 49
为了使您的代码有效,您不能将任何标记放在<ul>
除了<li>
.
但是,您可以将任何块级元素放入其中<li>
,如下所示:
<ul>
<li>
<h2>...</h2>
<p>...</p>
<p>...</p>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
Яeg*_*ght 12
根据W3C建议书,列表的基本结构必须是:
<UL>
<LI> ... first list item...
<LI> ... second list item...
...
</UL>
Run Code Online (Sandbox Code Playgroud)
您只能将p
标签放在标签内li
,而不是直接放在标签中ul
.W3C建议明确指出:
列表由LI元素定义的列表项序列组成
您可以使用模板标签,这是完全合法的。例如:
<ul>
<template>Some text here or <p>Some text here<p> etc</template>
<li>item 1</li>
<template>Some text here or <p>Some text here<p> etc</template>
<li>item 1</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
虽然你可以在里面有其他标签(它可能工作得很好),你不应该因为它不符合w3c.它的语义也很少.
只需创建一个简单的页面并通过验证器(http://validator.w3.org/)运行它,你就会看到自己:)