0

像这样?

<li>Menu1</li><div></div>
<li>Menu2</li><div></div>

我这样做的原因是使用 CSS 为 div 设置样式,以制作带有渐变的分隔符。

4

4 回答 4

2

Nope. You can check for yourself here: http://validator.w3.org/

You might be able to get a similar result using the CSS pseudo-element ::after, depending on how you're styling your <li>s.

E.g.

li {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-block;
}

li::after {
    display: inline-block;
    content: "";
    width: 10px;
    height: 10px;
    background: #000;
}

Apply gradient backgrounds as desired.

Note that to support IE8, you'll need to use the older syntax :after instead, and IE 7 doesn't support this pseudo-element at all.

于 2013-08-30T10:46:20.563 回答
2

不,此 HTML 结构无效。

a 的允许内容<ul>是零个或多个<li>元素

参考: http ://www.w3.org/TR/html-markup/ul.html#ul-content-model

于 2013-08-30T10:51:19.867 回答
1

你最好这样使用,

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>Menu1</li>
        <li><div></div></li>
        <li>Menu2</li>
        <div></div>
    </ul>
</body>

于 2013-08-30T13:34:04.523 回答
1

不!检查它:http: //validator.w3.org/

编辑验证此代码以查看它是否无效:

<!doctype html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>

    <body>
        <ul>
            <li>Menu1</li>
            <div></div>
            <li>Menu2</li>
            <div></div>
        </ul>
    </body>

</html>
于 2013-08-30T10:48:05.887 回答