HTML <label> tag

Updated: 10/11/2017 by Computer Hope

HTML label tagWhen writing in HTML, the <label> tag is used to create labels for items in a user interface. Typically used within <input> tags on a form, the <label> tag is additionally useful because it extends the clickable area of control elements, like buttons. The following sections contain information about the <label> tag, including an example of it in use, as well as related attributes and browser compatibility.

Note: The <label> tag belongs to a group of tags called form elements.

Example code

<h3>Which type of pet do you prefer?</h3>
<form>
<label for="dogs">Dogs</label>
<input type="radio" name="animal" id="dogs" value="dogs"><br><br>
<label for="cats">Cats</label>
<input type="radio" name="animal" id="cats" value="cats"><br><br>
<input type="submit" value="Submit">
</form>

Example result

Which type of pet do you prefer?





Attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <label> tag, as well as a description of each.

Attribute Description
for Designates which form element a label is describing
form Designates the form to which a label belongs

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All version All versions All versions

Additional form elements

Browser, Compatibility, Form, User interface, Web design terms, Web page