Accessibility · Junior · Question 25 of 75

How do you correctly connect a label to an input?

<label for="email">Email</label>
<input id="email" type="email" />
Show the answer

Correct answer: Like this: for matches the id of the input

Explanation

The label gives the field its accessible name and enlarges the click target. Wrapping the input inside <label> also works.

Further reading

Problem with a question

Accessibility · Junior · question 25

Test yourself

Take the Accessibility · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz