[英]The for attribute of the label element must refer to a non-hidden form control <label for=“Country” >Countr
<div class="needContent">
<label for="Country" >Country</label>
<input list="browsers" name="Country" required="required">
<datalist id="browsers">
<option value="Canada">
<option value="The United States">
<option value="India">
<option value="Pakistan">
<option value="Germany">
</datalist>
</div>
Hi, I am new to html.I am trying to validate my file on html validator but it is giving me the error specified above. 嗨,我是html的新手,我试图在html验证器上验证我的文件,但这给了我上面指定的错误。 Can someone help me to fix that please?
有人可以帮我解决这个问题吗?
The problem is that the for
attribute of <label>
corresponds to the element's ID , not its name
: 问题是
<label>
的for
属性对应于元素的ID ,而不是其name
:
for
To resolve this, all you have to do is give your <input>
element an id
that is the same as its name
. 要解决此问题,您要做的就是为您的
<input>
元素提供一个与name
相同的id
。 Note that you'll probably also want to ensure that both of these are lowercase to prevent confusion: 请注意,您可能还需要确保两者均为小写形式,以防止混淆:
<div class="needContent"> <label for="country">Country</label> <input list="browsers" id="country" name="country" required="required"> <datalist id="browsers"> <option value="Canada"> <option value="The United States"> <option value="India"> <option value="Pakistan"> <option value="Germany"> </datalist> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.