这两者之间哪个符合标准?
<p>Text text text ...
<ol>
<li>First element</li>
</ol>
</p>
<p>
Other text text ...
</p>
OR
<p>
Text text text ...
</p>
<ol>
<li>First element</li>
</ol>
<p>
Other text text ...
</p>
简短的回答是ol
法律不允许的元素在里面p
元素。
要了解原因,让我们转到规范 http://www.w3.org/TR/html5/!如果您能够熟悉 HTML 规范,它将回答您的许多问题和好奇心。您想知道是否ol
可以住在里面p
. So…
4.5.1 的p element http://www.w3.org/TR/html5/grouping-content.html#the-p-element:
类别: 流量内容 http://www.w3.org/TR/html5/dom.html#flow-content-1, 触手可及的内容 http://www.w3.org/TR/html5/dom.html#palpable-content.
内容模型: 措辞内容 http://www.w3.org/TR/html5/dom.html#phrasing-content-1.
4.5.5 的ol element http://www.w3.org/TR/html5/grouping-content.html#the-ol-element:
类别: 流量内容 http://www.w3.org/TR/html5/dom.html#flow-content-1.
内容模型: 零个或多个li http://www.w3.org/TR/html5/grouping-content.html#the-li-element and 脚本支持 http://www.w3.org/TR/html5/dom.html#script-supporting-elements-0元素。
第一部分说p
元素只能包含措辞内容 http://www.w3.org/TR/html5/dom.html#phrasing-content-1(这是“内联”元素,例如span
and strong
).
第二部分说ol
s are 流动内容 http://www.w3.org/TR/html5/dom.html#flow-content-1(“块”元素,例如p
and div
)。所以他们can't在 a 内使用p
.
ol
和其他flow content
可以用在其他一些元素中,例如div
:
4.5.13 的div element http://www.w3.org/TR/html5/grouping-content.html#the-div-element:
类别: 流量内容 http://www.w3.org/TR/html5/dom.html#flow-content-1, 触手可及的内容 http://www.w3.org/TR/html5/dom.html#palpable-content.
内容模型: 流量内容 http://www.w3.org/TR/html5/dom.html#flow-content-1.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)