两个代码都完全有效,但是哪个在语义上是正确的?
两个代码都完全有效,但是哪个在语义上是正确的?
它有
<ol>
<li>
<h2>heading level 2</h2>
<p>
some long text here some long text here some long text
here some long text here some long text here some long
text here some long text here some long text here
</p>
</li>
</ol>
这是没有
<ol>
<li>
<h2>heading level 2</h2>
some long text here some long text here some long
text here some long text here some long text here
some long text here some long text here some long text here
</li>
</ol>
Both code are perfectly valid , but which is semantically correct?
It has <p>
<ol>
<li>
<h2>heading level 2</h2>
<p>
some long text here some long text here some long text
here some long text here some long text here some long
text here some long text here some long text here
</p>
</li>
</ol>
This is without <p>
<ol>
<li>
<h2>heading level 2</h2>
some long text here some long text here some long
text here some long text here some long text here
some long text here some long text here some long text here
</li>
</ol>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于文本是否是段落。可能是,但很难从占位符内容中看出。
(这假设将内容作为有序列表项在语义上首先是正确的。)
That depends on if the text is a paragraph or not. It probably is, but it is hard to tell from the placeholder content.
(This assumes that having the content as an ordered list item is semantically correct in the first place.)
最好使标记与网站易于关联。因此,我选择
版本,以便我的代码的读者可以更轻松地了解网站的结构。
It's best to keep the markup easily associable with the website. Therefore, I'd choose the
<p>
version so readers of my code could more easily follow the website's structure.