Elements – Label Tag


Label Tag

<label> defines a label for an <input> type element/tag.

Usage

<label for="id">Label</label> <input type="text" name="text" id="id" value="yourvalue"><br>

As you can see, the for attribute of the <label> tag should be equal to the id attribute of the related element to bind them together.

Platform Support

BrowserElement Support
Internet ExplorerYes
Mozilla FirefoxYes
Google ChromeYes
OperaYes
SafariYes

Attributes

AttributeValueDescription
forelement_idSpecifies which form element a label is bound to
formform_idSpecifies one or more forms the label belongs to

Global Attribute

The <label> tag supports the Global Attributes in HTML.

Event Attribute

The <label> tag supports the Event Attributes in HTML.

The <label> element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the element, it toggles the control.

More Information:

MDN – Label Tag
W3School – Label Tag

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.