我可以使用div作为UL的直接子吗? [英] Can I use div as a direct child of UL?
问题描述
我有这个代码:
<ul>
<div>
</div>
</ul>
我的浏览器没有出现问题。我也读过这个地方,李应该只被用作'ul的直接孩子。它是否正确?我不能使用div作为UL的直接孩子吗?有上述混淆的文档吗?
I feel no issue in my browser rendering it. I have read this too somewhere that 'li' should only be used as direct child of 'ul. Is this correct? Can't I use div as a direct child of UL? Is there any documentation for the above confusion?
编辑:此链接说明我可以 http://css-tricks.com/forums/discussion/11593/divs-inside-uls/p1
This link says I can http://css-tricks.com/forums/discussion/11593/divs-inside-uls/p1
推荐答案
否。可能是< ul>
的子元素的唯一元素是< li>
。
No. The only element that may be a child of <ul>
is <li>
.
HTML 4 :
<!ELEMENT UL - - (LI)+ -- unordered list -->
(另请参阅如何读取DTD中的内容模型定义)
< a href =http://www.w3.org/TR/html5/the-ul-element.html#the-ul-element =noreferrer> HTML 5 :
内容模型:
零个或多个li元素。
Content model: Zero or more li elements.
这篇关于我可以使用div作为UL的直接子吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!