Reputation: 33
I am getting a w3c validation error here as
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>").
This is my source code
<ul class="link">
<li><a href="" class="selected"><span>1<div class="clr"> </div><label>Vul Postcode in </label></span></a></li>
<li><a href=""><span>2<div class="clr"> </div><label>Restaurants </label></span></a></li>
<li><a href=""><span>3<div class="clr"> </div><label>Menukaart</label></span></a></li>
<li><a href=""><span>4<div class="clr"> </div><label>Afrekenen</label></span></a></li>
</ul>
Please help me to find out the issue,
Thanks
Pallavi
Upvotes: 1
Views: 9213
Reputation: 96587
You have a block element (div
) inside of an inline element (span
). This is not allowed.
Solution 1: Change span
to div
:
<a href=""><div>2<div class="clr"> </div><span class="label">Restaurants </span></div></a>
(You have to use HTML5 (<!DOCTYPE html>
), otherwise block elements wouldn’t be allowed inside of a
elements.)
Solution 2: Change div
to span
:
<a href=""><span>2<span class="clr"> </span><span class="label">Restaurants </span></span></a>
Note that you can’t have label
inside of an a
element (I changed the label
to span
here). Use the label
element only when you have a form
.
Upvotes: 1