New! My 44-page ebook "CSS in 44 minutes" is out! 😃

Get it now →

# label

Defines a label for a form control.

Example: Copy


<label for="first_name">First name</label>
<br>
<input type="text" name="first_name" id="first_name">

Example: Copy

<label>
<input type="checkbox" name="terms">
I agree to the terms
</label>

Example: Copy

Subscribe to the newsletter?

<p>Subscribe to the newsletter?</p>
<label>
<input type="radio" name="newsletter" value="yes"> Yes
</label>
<label>
<input type="radio" name="newsletter" value="no"> No
</label>

for

Defines which control the label is associated with.

"last_name"

Clicking the label will focus on the input with the id equal to last_name.

<label for="last_name">Last name</label>
<br>
<input type="text" name="last_name" id="last_name">