<li>在没有包装<ul>的情况下不在ie 8中显示

时间:2018-11-05 16:08:01

标签: html internet-explorer-8

<p>
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</p>

    <li>
        this is a test &quot;li&quot; without a parent &quot;ul&quot;</li>
    <li>
        this is a test &quot;li&quot; without a parent &quot;ul&quot;</li>
    <li>
        this is a test &quot;li&quot; without a parent &quot;ul&quot;</li>
    <li>
        this is a test &quot;li&quot; without a parent &quot;ul&quot;</li>

以上列表项未包装在<ul>标记中时将不会在IE8中显示。是错误还是预期的行为?

3 个答案:

答案 0 :(得分:1)

specification要求<li>元素是特定父元素的子元素。您的示例中似乎缺少<li>的父元素。

不是规范,而是Mozilla’s documentation

  

HTML <li>元素用于表示列表中的项目。 必须   包含在父元素中:有序列表(<ol>),无序列表   列表(<ul>)或菜单(<menu>)。

答案 1 :(得分:0)

li代表“列表元素”。因此,您应该将它们放在ul(无序列表)或ol(有序列表)中。 单独使用li标记可能会在现代浏览器中工作(但HTML代码不符合您使用的标准),但在Internet Explorer 8中则无效!

答案 2 :(得分:0)

首先,这不是使用 Li 而没有 ol UL 的正确语法。

如果然后您还想在IE 8中显示列表而不添加 ul ol ,请尝试创建一个识别IE 8的JS函数。

如果是IE 8,则循环遍历所有 li 元素。

然后在文本前添加'•'字符。

它看起来像带有 li 元素的项目符号。

•一个

•两个

•三