如果没有他们在< ul>下面,你可以拥有< li>或< ol> ;? [英] Can you have <li>s without them being under a <ul> or <ol>?
问题描述
我有一个导航,我正在使用一个列表。我把它放在< ul>
中,但是这弄乱了我的UI,因为它有奇怪的自动边距。我试过没有< ul>
,他们似乎工作。这可以跨所有浏览器使用吗?这合法吗?其他人之前做过这些吗?
I have a navigation that I am using a list for. I have it in a <ul>
, but that is messing up my UI because it has weird automatic margins. I tried without the <ul>
and they seem to work. Would this work across all browsers? Is this legal? Anybody else done this before?
推荐答案
它可能在浏览器中工作,因为浏览器太宽容了,但这是无效的 validator :
It's probably working in browsers because browsers are too forgiving, but that's not valid says the validator:
文档类型不允许元素li在这里;缺少ul,ol,menu,dirstart-tag之一
Document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag
您可以删除CSS中的自定义边距。这是你唯一的解决方案。通常,您可以通过以下方式在所有 < ul>
标签中移除它:
Well, you can remove customize margins in CSS. That's your only solution. Generally, you can remove it on all <ul>
tags in the documents by:
ul {
margin: 0;
padding: 0;
}
如果您想知道 padding code>是,请参阅此处。
In case you're wondering what padding
is, see it here.
这篇关于如果没有他们在< ul>下面,你可以拥有< li>或< ol> ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!