HTML <label>Tag


Examples

A simple HTML form with two input fields and associated labels:

<form action="demo_form.php"> <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><br> <input type="submit" value="Submit"> </form>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Most browsers currently support the <label> tag.


Tag Definition and Usage Instructions

The <label> tag defines a label (mark) for the input element.

The label element does not render any special effects to the user. However, it improves usability for mouse users. If you click text within the label element, this control is triggered. That is, when the user selects the label, the browser automatically transfers focus to the form control associated with the label.

The for attribute of the <label> tag should be the same as the id attribute of the related element.


Tips and Notes

Tip:The "for" attribute can bind the label to another element. Set the value of the "for" attribute to the value of the id attribute of the related element.


Differences Between HTML 4.01 and HTML5

The "form" attribute is new in HTML5.


Attributes

New: New in HTML5.

Attribute Value Description
for element_id Specifies which form element the label is bound to.
formNew form_id Specifies one or more forms to which the label field belongs.


Global Attributes

The <label> tag supports global attributes. View the full attribute tableHTML Global Attributes。


Event Attributes

The <label> tag supports allHTML Event Attributes。

Other Extensions