Label HTML

HTML <label> Tag:

To define a label for an input element, the HTML <label> Tag is used. To write a parser, browser-friendly and user-friendly, the use of HTML <label> Tag is recommended in HTML forms.


<!DOCTYPE html>  
<label for="name">Name:</label><br/>  
<input type="text" id="name" name="name"/> <br/>  
<label for="city">City:</label><br/>
<input type="text" id="city" name="city"/> <br/>  


In the above example, we created two one-line text input fields with labels for each.

Global Attributes:

The HTML Global attributes are supported by the HTML <label> tag.

Event Attributes:

The HTML Event attributes are supported by the HTML <label> tag.

Supporting Browsers:

Chrome, IE, Firefox, Opera, and Safari.