HTML <label> forAttribute

HTML label 标签参考手册HTML <label> Tag

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>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 标签参考手册HTML <label> Tag Other Extensions