Alex Rivera | Logout

Is it important to use <label> in HTML?

Asked 2010-10-08T18:05:26.600
17

Excuse me for the maybe very stupid question, but my curiosity is killing me, and plus I'm new to this, but are using labels important in your markup, and why?

i.e.

<label for="birthdate">Birthdate:</label>
<input type="text" id="birthdate" name="birthdate" />

Why must I label this input, why is it beneficial to the user, why is going to be beneficial for future use, or is it search engine optimization thing. That's what I really wanna know :)

Edit
Report

1 Answer

34

It's important for a number of reasons:

  • Clicking the label focuses on the
    text field, which is something a lot of users expect.
  • It's helpful for the accessibility reasons.
  • How else is the user going to know which field is which? You could use just text or a span or something, but why would you?
  • It leads to a more semantic markup.
answered 2010-10-08T18:08:17.143

Your Answer