12

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>
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
Sato
  • 8,192
  • 17
  • 60
  • 115
  • 1
    The answer is here: http://stackoverflow.com/questions/12894169/what-is-the-html-for-attribute – Felix Jun 06 '16 at 02:12
  • 3
    Possible duplicate of [What does "for" attribute do in HTML – Jeff Puckett Jun 06 '16 at 02:13
  • I thought its a bootstrap feature :) – Sato Jun 06 '16 at 03:26
  • Possible duplicate of [What is the HTML for="" attribute in – Jonas Praem Dec 17 '18 at 20:07

2 Answers2

13

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.

stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
2

for specifies the element id to which the label belongs.

Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • Which explains it's purpose in HTML. But question specifically asks for the purpose in Bootstrap. – Ferit Mar 26 '19 at 15:44