简体   繁体   English

W3C验证错误

[英]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. 我一直在努力寻找解决此W3C HTML验证错误的解决方案,其数量超出了我应有的范围。 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 HTML代码

<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">

The ID of a labelable form-related element in the same document as the label element. 与label元素在同一文档中的与labelable表单相关的元素的ID。 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. 文档中具有与for属性的值匹配的ID的第一个此类元素是此label元素的带标签的控件。

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; <img id="location"更改为表单控件; input, textarea, button, or select. 输入,文本区域,按钮或选择。

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

The purpose of a label is to describe a form element. label的目的是描述表单元素。 When using a label , the for attribute needs to be the same as the id of the form element it is describing. 使用labelfor属性必须与其所描述的form元素的id相同。

<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 id ed correctly. 之所以出现此错误,是因为您为不存在或未正确id的表单元素提供了for属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM