HTML <label> Tag

Advertisements


Description

The HTML <label> tag is used to add a label to a form control like text, textarea etc.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML label Tag</title>
</head>
<body>
<label for="email">EMAIL-ID:<br /> <input type="email" value="" name="emailid" size="30" placeholder="Enter a valid email address"><br /><br />
<label for="phone">PHONE NO:<br /> <input type="text" value="" name="phno" size="30" maxlength="10" placeholder="Enter a valid phone number" pattern="[0-9]{10}"><br /><br />
</body>
</html>

This will produce following result:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <label> tag also supports following additional attributes:

AttributeValueDescription
formhtml-5form_idIt specifies one or more forms the label belongs to
forcontrol idSpecifies the input control that this label is for. This value must be the same as the value in the input control's "id" attribute.

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm

Advertisements