HTML <label> tag
Updated: 09/12/2023 by Computer Hope
When writing in HTML (hypertext markup language), the <label> tag creates labels for items in a user interface. 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, and related attributes and browser compatibility.
Note
The <label> tag belongs to a group of tags called form elements.
Example of <label> 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
All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <label> tag has the following unique attributes.
Attribute | Description |
---|---|
for | Designates which form element a label is describing. |
form | Designates the form where a label belongs. |
Compatibility
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All version | All versions | All versions |
Additional form elements
- <button>
- <datalist>
- <fieldset>
- <input>
- <keygen>
- <legend>
- <optgroup>
- <option>
- <output>
- <select>
- <textarea>
Browser, Compatibility, Form, User interface, Web design terms, Web page