I understand the for
attribute specifies which form
element a label
is bound to.
Do you have an example where this would be actually useful?
It's most useful for a checkbox label where it will make the whole label clickable so you don't have to target the checkbox itself to toggle its state. Same for radio buttons.
<label for="email">E-mail:</label>
<input type="text" id="email" name="email"/>
Now if you click on "E-mail", the corresponding input
element will get focused.
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