HTML <label> formAttribute
Examples
A <label> element located outside the form (but still part of the form):
<form action="demo_form.html" id="form1">
<input type="radio" name="sex" id="male" value="male"><br>
<label for="female">Female</label>
<input type="radio" name="sex" id="female" value="female">
<input type="submit" value="提交">
</form>
<label for="male" form="form1">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">
<input type="submit" value="提交">
</form>
<label for="male" form="form1">Male</label>
Try it yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the form attribute.
Definition and Usage
The form attribute specifies one or more forms to which the <label> element belongs.
Differences between HTML 4.01 and HTML5
The form attribute is a new attribute in HTML5.
Syntax
<label form="form_id">
Attribute Values
| Value | Description |
|---|---|
| form_id | A space-separated list of ids of one or more forms to which the <label> element belongs. |
HTML <label> tag Other extensions