文档类型不允许元素“div”在这里;缺少“object”,“applet”,“map”,“iframe”,“button”,“ins”,“del”start-tag

时间:2013-05-02 10:47:09

标签: w3c-validation

我在这里得到了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>

请帮我找出问题,

由于

Pallavi

1 个答案:

答案 0 :(得分:1)

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

  • 解决方案1:将span更改为div

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

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

  • 解决方案2:将div更改为span

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

请注意,label元素中没有a(我在此处将label更改为span)。仅当您拥有label时才使用form元素。