Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use label element with select?

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> 
like image 860
P K Avatar asked Apr 12 '12 18:04

P K


People also ask

Which is the label element used for?

The <label> element is used to associate a text label with a form <input> field. The label is used to tell users the value that should be entered in the associated input field.

What tags can be used using select tag?

Select tag in HTML is used to display the selection list to choose one or multiple options from the selection list. <select> tag can be used with values like selected, required, disabled, required, autofill, autofocus, link, size, multiple, placeholder, optgroup, and many more.


1 Answers

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

like image 86
ThiefMaster Avatar answered Sep 20 '22 12:09

ThiefMaster