The HTML <label></label> element defines a label for an <input /> element. This element provides a usability improvement for mouse users, because if the user clicks on the text within the <label> element, it toggles the control. This element's for attribute should be equal to the id attribute of the related element to bind them together.
Attributes
| Attribute | Value | Description |
|---|---|---|
for |
id of another field | Defines which <form> element the label is for. Set to an ID of a <form> element. If this attribute is not specified, the label is associated with its contents.
|
form |
formname | Defines one or more forms the label field belongs to. |
HTML example:
<form>
<label for="male">Male</label>
<input type="radio" name="sex" id="male" />
<br />
<label for="female">Female</label>
<input type="radio" name="sex" id="female" />
</form>