gpt4 book ai didi

html - 这个 HTML 结构有效吗? UL > DIV > { LI, LI } , DIV > { LI, LI } , DIV > { LI, LI }

转载 作者:技术小花猫 更新时间:2023-10-29 12:23:44 27 4
gpt4 key购买 nike

这个 HTML 结构有效吗?

<ul class="blog-category">
<div class="three column">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</div>
<div class="three column">
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</div>
<div class="three column">
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
</div>
</ul>

我将 li 插入到 ul 内的 div 中。你怎么看?这种结构在语义上是否有效,是否会被识别为单个列表?

最佳答案

不,div 不允许作为 ul 的直接子级。每当您有疑问时,validate your page with W3C或查看 the corresponding article on W3C :

4.5.6 The ul element

Categories
Flow content.

Contexts in which this element can be used:
Where flow content is expected.

Content model:
Zero or more li elements.

Content attributes:
Global attributes

DOM interface:
interface HTMLUListElement : HTMLElement {};

相反你可以使用

<ul class="blog-category">
<li class="three column">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</li>
<li class="three column">
<ul>
<li>Item 4</li>
...
</ul>
</li>
</ul>



关于html - 这个 HTML 结构有效吗? UL > DIV > { LI, LI } , DIV > { LI, LI } , DIV > { LI, LI },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8557869/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com