我一直在努力寻找这个W3C HTML验证错误的解决方案,这超出了我的能力范围。我还是想不出怎么解决这个问题。如果这里有人能帮我,那就太好了。
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代码
<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">发布于 2013-03-22 21:22:06
与label元素位于同一文档中的可标记表单相关元素的ID。文档中ID与for属性值匹配的第一个此类元素是该label元素的label控件。
代码中没有表单控件。label元素的唯一用途是标记表单控件。将<img id="location"更改为表单控件;输入、文本区、按钮或选择。
发布于 2013-03-22 21:26:27
label的目的是描述表单元素。在使用表单时,for属性需要与它所描述的label元素的id相同。
<label for="location">Location:</label><input type="text" id="location" name="location" />出现此错误的原因是,您正在为不存在或未正确id的表单元素提供for属性。
https://stackoverflow.com/questions/15571402
复制相似问题