+ 3

use of "FOR" attribute in html

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

4th Apr 2018, 6:41 PM
Smriti Rastogi
Smriti Rastogi - avatar
5 Answers
+ 3
<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:44 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 3
I wonder how we can create the password from dots to*******. Do you guys agree?
5th Apr 2018, 6:36 PM
Saba
+ 2
When used together with the <label> element, the for attribute specifies which form element a label is bound to.
4th Apr 2018, 6:43 PM
Smriti Rastogi
Smriti Rastogi - avatar
+ 2
Yes, I'm referring to the ID, but I see what you're saying when I read it again. I meant the input with the same name, but not as in its name attribute. However, you're absolutely correct; it's based upon the ID of the element. *edit* I put it in parenthesis to prevent any confusion.
4th Apr 2018, 7:19 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
Simple correction: the label seeks for the id not the name attribute.
4th Apr 2018, 7:13 PM
CHMD
CHMD - avatar