Very recently, I have searched in Google to know the use of it. Now I have come to know that, the "for" attribute of label binds the label with the corresponding control. Binding in the sense, when the user clicks on the label it toggles the corresponding control (control id passed as value for "for" attribute). This way the "for" attribute is used for the label. Now onwards I am going to make a good practice of using "for" attribute of the label control.
Let's see an example of the usage of the "for" attribute of label control
<label for="FirstName">First Name:</label>
<input id="FirstName" type="text">
The above code is rendered as shown below. You can test this behavior by clicking on the label "First Name:". You can notice the text box focused.
7 comments:
Thanks a lot for the info, which has not been mentioned in w3 schools.
this fact may be small, but good to find out
Thanks
Good info!
basic info.
Nice info. Thanks :)
This little attribute was itching me.. Now I got it.
Bad that the linking is not working on name attribute of <input></input> tag.
Post a Comment