HTML label - how to use <label> tag

The HTML <label> tag is used to define a label for the input tag. Though it is a great help to have a label but it helps the user to click on the label and to get focus on the related field.


The label tag supports the global and event attributes.

Defines the id of the input tag that the label is tied to
Defines one or multiple id of the form that this label belongs to


<!--nesting input tag within label--> <label>Click here <input type="text" id="t1" /></label> <!--using the for attribute--> <label for="fname">First Name</label> <input type="text" id="fname" />