Is there a best practice concerning the nesting of label
and input
HTML elements?
classic way:
One thing you need to consider is the interaction of checkbox and radio inputs with javascript.
Using below structure:
When user clicks on "Label text" controlCheckbox() function will be fired once.
But when input tag is clicked the controlCheckbox() function may be fired twice in some older browsers. That's because both input and label tags trigger onclick event attached to checkbox.
Then you may have some bugs in your checkboxState.
I've run into this issue lately on IE11. I'm not sure if modern browsers have troubles with this structure.