Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is 'for' used for in bootstrap form label?

I don't know the meaning of for="inputEmail3", seems its same as id, what is it for? Can I just remove for="inputEmail3" ?

<form>
  <div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 form-control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
like image 541
Sato Avatar asked Jun 06 '16 02:06

Sato


2 Answers

If you click on the label with your mouse, then the cursor will automagically jump to the input specified in the 'for' attribute. It's really useful, don't remove it.

like image 106
stephenmurdoch Avatar answered Oct 19 '22 00:10

stephenmurdoch


for specifies the element id to which the label belongs.

like image 36
Jeff Puckett Avatar answered Oct 19 '22 00:10

Jeff Puckett