Associate label to input with class not id?

Viewed 26103

I know that you can associate a label with an input using the for and id attributes. However can you use a class and not an id? Thanks

<label for="rooms">Number of rooms</label>
<select id="rooms">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
</select>
5 Answers

you can do this :

<label class="col-md-12 input-group input-group-sm">
    <span class="col-sm-5 control-label text-nowrap">Code</span>
    <input class="form-control listen code" type="text" size="15" required/>
</label>
Related