HTML <label> Tag
Description
The <label>
HTML element establishes a connection between a certain label, which is usually the text, and a form element ( <input>
, <select>
, <textarea>
). Such a relationship is necessary in order to change the values of form elements when the mouse clicks on the text. In addition, using <label>
you can set keyboard shortcuts and switch to the active element like links.
Properties
- Permitted Parents
- Any element that accepts phrasing content
- Content
- Inline and text
- Start/End Tags
- Start tag: required, End tag: required
Example
<form>
<label for="male">Male</label>
<input type="radio" name="sex" id="male" />
<label for="female">Female</label>
<input type="radio" name="sex" id="female" />
</form>
Attributes
Attribute | Definition |
---|---|
for | Specifies the input control that this label is for. This value must be the same as the value in the input control's "id" attribute. |
Global Attributes
The <label>
tag also supports the Global Attributes in HTML5
Event Attributes
The <label>
tag also supports the Event Attributes in HTML5
Browser Support
The following table will show you the current browser support for the HTML <label>
tag.
Desktop | |||||
12 | 1 | 1 | 15 | 4 |
Tablets / Mobile | |||||
18 | 4 | 14 | 3.2 | 1 | 4.4 |
Last updated by CSSPortal on: 30th March 2024