1

我在这里收到一个 w3c 验证错误

    The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

    One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

这是我的源代码

<ul class="link">
    <li><a href="" class="selected"><span>1<div class="clr">&nbsp;</div><label>Vul Postcode in </label></span></a></li>
    <li><a href=""><span>2<div class="clr">&nbsp;</div><label>Restaurants </label></span></a></li>
    <li><a href=""><span>3<div class="clr">&nbsp;</div><label>Menukaart</label></span></a></li>
    <li><a href=""><span>4<div class="clr">&nbsp;</div><label>Afrekenen</label></span></a></li>
</ul>

请帮我找出问题,

谢谢

帕拉维

4

1 回答 1

1

div内联元素 ( ) 中有一个块元素( span)。这是不允许的。

  • 解决方案 1:更改spandiv

    <a href=""><div>2<div class="clr">&nbsp;</div><span class="label">Restaurants </span></div></a>
    

    (您必须使用 HTML5 ( <!DOCTYPE html>),否则不允许在元素内部使用块a元素。)

  • 解决方案 2:更改divspan

    <a href=""><span>2<span class="clr">&nbsp;</span><span class="label">Restaurants </span></span></a>
    

请注意,您不能在元素label内部(我将其更改为此处)。仅当您有.alabelspanlabelform

于 2013-05-02T21:34:03.630 回答