user2199351
user2199351

Reputation: 103

W3C validation for error

I have been trying to look for a solution for this W3C HTML validation error for more than I should be. I still can't figure out how to solve this. If anyone in here could help me out, that would be great.

Line 109, Column 27: The for attribute of the label element must refer to a form control. 
                    <label for="location">Location</label>

Line 162, Column 27: The for attribute of the label element must refer to a form control. 
                    <label for="location">Location</label> 

HTML CODE

<fieldset id="meat">
    <legend>Meat Toppings</legend>
       <label for="location">Location</label>
        <img  src="full.png" alt="full">
        <img src="left.png" alt="left">
        <img src="right.png" alt="right">
        <img id="location" src="none.png" alt="none">

Upvotes: 1

Views: 307

Answers (2)

Quentin
Quentin

Reputation: 943099

The ID of a labelable form-related element in the same document as the label element. The first such element in the document with an ID matching the value of the for attribute is the labeled control for this label element.

You have no form controls in the code. The sole purpose of a label element is to label a form control. Change <img id="location" into a form control; input, textarea, button, or select.

https://developer.mozilla.org/en-US/docs/HTML/Element/label

Upvotes: 1

Michael Irigoyen
Michael Irigoyen

Reputation: 22947

The purpose of a label is to describe a form element. When using a label, the for attribute needs to be the same as the id of the form element it is describing.

<label for="location">Location:</label><input type="text" id="location" name="location" />

You are getting this error because you are supplying a for attribute for a form element that does not exist, or is not ided correctly.

Upvotes: 1

Related Questions