Can I use label element with select?
Asked Answered
H

1

42

Can I use label element with select?

Most of the places I see label example with input elements only.

What does standard say about label association?

Is it a valid HTML markup?

<label for="id_select"> Options </label>
<select id="id_select" autofocus="true">
  <option value="1"> Option1 </option>
  <option value="2"> Option2 </option>
</select>
Heritable answered 12/4, 2012 at 18:36 Comment(0)
O
46

Yes, it's valid and works fine.

This attribute explicitly associates the label being defined with another control.

http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1

Outfit answered 12/4, 2012 at 18:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.