Skip to main content
edited title
Link
SuperStormer
  • 5.5k
  • 5
  • 30
  • 40

What does "for" attribute do in an HTML <label> tag?

added 6 characters in body; edited tags
Source Link
HDJEMAI
  • 9.9k
  • 48
  • 78
  • 99

I wonder what is the difference between the following two code snippets:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>
<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>
<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

I wonder what is the difference between the following two code snippets:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

I wonder what is the difference between the following two code snippets:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

Question Protected by Gurwinder Singh
added 16 characters in body
Source Link
Gurwinder Singh
  • 39.7k
  • 6
  • 62
  • 87

I wonder what is the difference between thesethe following two codescode snippets:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

I wonder what is the difference between these two codes:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

I wonder what is the difference between the following two code snippets:

<label>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

and

<label for='theinput'>Input here : </label>
<input type='text' name='theinput' id='theinput'/>

I'm sure it does something when you use a special JavaScript library, but apart from that, does it validate the HTML or required for some other reason?

edited body
Source Link
jeff
  • 13.8k
  • 32
  • 86
  • 139
Loading
deleted 94 characters in body; edited title
Source Link
Michał Perłakowski
  • 93.5k
  • 30
  • 165
  • 190
Loading
edited tags
Link
Deduplicator
  • 46k
  • 7
  • 75
  • 125
Loading
added 94 characters in body
Source Link
jeff
  • 13.8k
  • 32
  • 86
  • 139
Loading
deleted 14 characters in body
Source Link
jeff
  • 13.8k
  • 32
  • 86
  • 139
Loading
edited tags
Link
mu is too short
  • 436.6k
  • 71
  • 863
  • 822
Loading
Source Link
jeff
  • 13.8k
  • 32
  • 86
  • 139
Loading