Skip to main content
Notice removed Current answers are outdated by Brendan
Bounty Ended with WebMonster's answer chosen by Brendan
Title seems to have caused confusion in an answer so I'm clarifying it to better align with the body of the question
Link

Is "for"attribute"for" attribute necessary in HTML label if the target input is nested inside the label?

Notice added Current answers are outdated by Brendan
Bounty Started worth 50 reputation by Brendan
added 5 characters in body; edited tags; edited title
Source Link
codeling
  • 11.5k
  • 6
  • 49
  • 76

Is "for"attribute necessary in HTML label?

I've noticed that a HTML label tag doesn't need the 'for' attribute when you put your input element into the label element:

<label><input type="text">Last name</label>

But I was wondering what's the best practise. Can anybody help me with that?

Thanks!

Is "for"attribute necessary?

I've noticed that a label tag doesn't need the 'for' attribute when you put your input element into the label element:

<label><input type="text">Last name</label>

But I was wondering what's the best practise. Can anybody help me with that?

Thanks!

Is "for"attribute necessary in HTML label?

I've noticed that a HTML label tag doesn't need the 'for' attribute when you put your input element into the label element:

<label><input type="text">Last name</label>

But I was wondering what's the best practise. Can anybody help me with that?

Thanks!

edited tags
Link
BoltClock
  • 729.4k
  • 165
  • 1.4k
  • 1.4k
edited tags
Link
WWW
  • 9.8k
  • 2
  • 32
  • 33
Loading
Source Link
Raapwerk
  • 629
  • 1
  • 7
  • 15
Loading