HTML <label> forAttribute
Example
Two radio buttons with labels:
<form action="demo_form.html">
<label for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
<label for="female">Female</label>
<input type="radio" name="sex" id="female" value="female"><br>
<input type="submit" value="Submit">
</form>
<label for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
<label for="female">Female</label>
<input type="radio" name="sex" id="female" value="female"><br>
<input type="submit" value="Submit">
</form>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the for attribute.
Definition and Usage
The for attribute specifies the form element to which the label is bound.
Differences Between HTML 4.01 and HTML5
None.
Syntax
<label for="element_id">
Attribute Values
| Value | Description |
|---|---|
| element_id | The id of the element to which the label is bound. |
HTML <label> Tag Other Extensions