0

Why is "for" used in HTML?

I have seen in many places that in HTML forms the for is used I am unable to understand why? I found this answer in Stackoverflow but was unable to understand it completely if possible can someone explain it in simple terms:- https://stackoverflow.com/questions/12894169/what-is-the-html-for-attribute-in-label

21st Nov 2021, 5:56 PM
Akash
Akash - avatar
1 Answer
+ 3
For attribute is usually used to link the label tag with the input tag related to it For example: <label for='firstName'>First Name</label> <input type='text' id='firstName'/> Note that the for attribute value should be the same value we use for the input id that's how the browser know they are linked together.
21st Nov 2021, 7:10 PM
iyoub