如果ol / ul在里面< p>或外面? [英] Should ol/ul be inside <p> or outside?
问题描述
< p>文字文字...
< p< ;醇>
< li>第一个元素< / li>
< / ol>
< / p>
< p>
其他文字文字...
< / p>
OR
< p为H.
文字文字...
< / p>
< ol>
< li>第一个元素< / li>
< / ol>
< p>
其他文字文字...
< / p>
简短的答案是 ol
元素在 p
元素内不合法。
要明白为什么, 转到规范!如果您可以习惯HTML规范,它将回答您的许多问题和好奇心。你想知道 ol
是否可以存在于 p
内。所以...
分类: 流内容。
内容模式l :零或多个 li 和脚本支持元素。
第一部分说 Which is standard compliant between these two ?
span
和 strong
)。 第二部分说 ol
s 流内容(块元素,如 p
和 div
)。所以他们不能用在 p
内。
ol
s和其他流量内容
可用于其他元素,如 div
:
<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>
The short answer is that ol
elements are not legally allowed inside p
elements.
To see why, let's go to the spec! If you can get comfortable with the HTML spec, it will answer many of your questions and curiosities. You want to know if an ol
can live inside a p
. So…
Categories: Flow content, Palpable content.
Content model: Phrasing content.
Categories: Flow content.
Content model: Zero or more li and script-supporting elements.
The first part says that p
elements can only contain phrasing content (which are "inline" elements like span
and strong
).
The second part says ol
s are flow content ("block" elements like p
and div
). So they can't be used inside a p
.
ol
s and other flow content
can be used in in some other elements like div
:
Categories: Flow content, Palpable content.
Content model: Flow content.
这篇关于如果ol / ul在里面< p>或外面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!