In HTML, What's the purpose of the attribute for in the label tag.
<label for = "Name">Name: </label>
<% = Html.TextBox("Name")%>
In the above sample, why the label tag has a for = "Name" attribute? To mark their association??? If I don't put for what gonna happen?
Thanks for helping
The for attribute specifies which form element the label is bound to.
The label element allows the user to give focus to a form element by clicking on an associate label. If you do not use the for attribute, this association will not be made.
If the user clicks on the label, and the for attribute matches that id of the respective control, it will toggle the control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With