use of "FOR" attribute in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

use of "FOR" attribute in html

<label for="email">Your e-mail address: </label>

4th Apr 2018, 6:40 PM
Smriti Rastogi
Smriti Rastogi - avatar
2 Answers
+ 3
When used together with the <output> element, the for attribute specifies the relationship between the result of the calculation, and the elements used in the calculation.
4th Apr 2018, 6:44 PM
Smriti Rastogi
Smriti Rastogi - avatar
+ 4
<label for="email>You Email Address:</label> <input name="email" id="email" type="email" /> ^the "for" attribute is referencing the input with the same name (ID attr). The purpose is so that if you click on the label, it'll put the cursor inside of the input box for you. Further resource: https://www.w3schools.com/tags/tag_label.asp
4th Apr 2018, 6:47 PM
Fata1 Err0r
Fata1 Err0r - avatar