label for input html code example

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: html input text

<label for="name">Name (4 to 8 characters):</label>

<input type="text" id="name" name="name" required
       minlength="4" maxlength="8" size="10">

Example 3: 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">