In the lessons we are told that it is best practice to use the ‘for’ attribute in a label, but doesn’t the nesting already associate the input to the label? What is the difference between using it and omitting it?
I did find that by doing so the user can click the label and that is the same as clicking the input. Is that it or is there more?
Thanks!
To add to the selected solution, because it doesn’t directly answer:
Looks like there is no difference between nested and explicitly stated since if nested the ‘for’ attribute is by default the content.
Labels don’t actually have to contain the element they’re a label for, in which case they need the id of the element they’re attached to as their for attribute.
For example: <label for="foo">Foo</label>...some other stuff...<input id="foo">