What is label element in HTML?

The <label> element is used to incorporate a text label with an <input> field. The label identifies the <input> field and informs users about what to enter in the field.

It is important to note that the <label> element only exists in relation to another element. In this case, it is associated with a form field (usually with some <input> element).

Syntax

<input id="first-name" name="first-name">
  <label for = "first-name"> First Name </label>

The for attribute identifies the <input> field to which the label is associated. The value in the for attribute should match the id of the <input> field.

Example

In the following example, we create three options using the checkbox type in the <input> field. Each label is associated with the <input> field through the for attribute.

Although it is possible to put unmarked text beside a form field to label it without the <label> element, having an associated label provides better usability. With a properly marked-up label, a user can easily select the option or zoom into it. This might not be noticeable in desktops or laptops, but it is an important feature in smartphones.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved