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
Edge Chrome Firefox Opera Safari
1211154
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184143.214.4

Last updated by CSSPortal on: 30th March 2024