How to Use The Label Tag in HTML with Example

The <label> tag in HTML is used to provide a usability improvement for mouse users i.e, if a user clicks on the text within the <label> element, it toggles the control.

Syntax

<label> form_content... </label>

Example 1: html input label


<!-- By reference -->

<label for="first_name">First Name</label>

<input type="text" id="first_name" name="first_name">

<!-- By wrapping -->

<label>First Name

 <input type="text" name="first_name">

</label>

Example 2: how to use the label tag in html


<label for="id_of_what_you're_labeling"></label>

<!-- for example-->

<label for="username"></label>

<input type="text" id="username">

#html

How to Use The Label Tag in HTML with Example
6.00 GEEK