">
" />
Easy Tutorial
❮ Att Input List Att Progress Max ❯

HTML <label> Tag

Example

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>

Browser Support

Most browsers currently support the <label> tag.


Definition and Usage

The <label> tag defines a label for an input element.

The label element does not render any special effects for the user. However, it improves usability for mouse users. If you click the text within the label element, it triggers the control. This means that when a user selects the label, the browser automatically focuses on the associated form control.

The for attribute of the <label> tag should be equal to 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

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

Global Attributes

The <label> tag supports global attributes. See the full list of HTML Global Attributes.


Event Attributes

The <label> tag supports all HTML Event Attributes.

❮ Att Input List Att Progress Max ❯