<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. 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
:
for
To resolve this, all you have to do is give your <input>
element an id
that is the same as its name
. 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.