Skip to content

<label> - The Label Element

Form Control HTML 4.0

The label element creates a text description for form controls. It improves accessibility and usability by associating descriptive text with input fields, making forms easier to use for everyone.

Result
<!-- Explicit association -->
<label for="field-id">Label text</label>
<input type="text" id="field-id" name="field">
<!-- Implicit association -->
<label>
Label text
<input type="text" name="field">
</label>

Labels can be associated with form controls explicitly (using for attribute) or implicitly (by wrapping the control).

AttributeDescriptionExample
forID of the associated form controlfor="email"

Use the for attribute matching the input’s id:

Result

Wrap the input inside the label:

Result

Clicking the label text focuses the associated input (and toggles checkboxes/radios):

Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result

Every form control needs an associated label:

<label for="email">Email:</label>
<input type="email" id="email" name="email">
Result
Result
Result

If visual design requires hiding labels, keep them accessible to screen readers:

Result
<label for="email">Email:</label>
<label for="phone">Phone Number:</label>
<!-- All labels above inputs -->
<label for="name">Name:</label>
<input type="text" id="name">
<label for="email">Email:</label>
<input type="email" id="email">
<label for="firstname">First Name:</label>
<input type="text" id="firstname" name="firstname">
<label for="lastname">Last Name:</label>
<input type="text" id="lastname" name="lastname">
BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE4+Full support

The <label> element has been supported since early browser versions and works consistently across all modern browsers.