
The HTML <label> tag specifies a label for following elements:
<meter>
<progress>
Example:
<!DOCTYPE html>
<html>
<body>
<div><h3>How many cats do you have?</h3>
<input type="checkbox" id="one" name="one" value="one">
<label for="one"> One</label><br>
<input type="checkbox" id="vehicle2" name="two" value="two">
<label for="two"> Two</label><br>
<input type="checkbox" id="two" name="three" value="three">
<label for="three"> Three</label><br>
<input type="checkbox" id="other" name="other" value="other">
<label for="other"> Other</label><br>
</div>
</body>
</html>
Output:
How many cats do you have?
Note: The for attribute of must be equal to the id attribute of the related elements to link them together.
Attributes:
for (value- element_id) – defines the id of the form element the label should be bound to.
form (value- form_id) – defines which form the label belongs to.
Enjoy coding!