<label>...</label>

HTML4 HTML5

Represents a caption for an input control (such as <input>, <select>, or <textarea>). Clicking the label focuses or activates the associated input control, improving UX and accessibility.

Both opening and closing tags are required.

Attributes:

Example 1

Code:

<label for="imie">Name:</label> <input type="text" id="imie" placeholder="Enter name">

The browser will interpret this code as follows:

Example 2

Code:

<form style="display: flex; flex-direction: column; gap: 12px; max-width: 300px;"> <div> <label for="username" style="display: block; font-weight: bold; margin-bottom: 4px;">Username:</label> <input type="text" id="username" placeholder="Enter username" style="width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;"> </div> <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;"> <input type="checkbox" id="terms"> <span>I accept terms and conditions</span> </label> </form>

The browser will interpret this code as follows: