HTML HTML Forms Choosing Options Create Checkboxes

John Haupenthal
John Haupenthal
2,749 Points

Why are we using <label> tags instead of just plain text for the text next to each radio button/checkbox?

Looking for clarification on what using a <label> tag with a "for" attribute does over simply typing the text we want to display. Thank you.

1 Answer

Steven Parker
Steven Parker
172,167 Points

You get a functional enhancement that way.

The for attribute of a label associates it with the control so clicking on the label will change the state of the control. This can provide a better experience for the user as the physical screen area of a check box or radio button is rather small, and allowing the text to act as a control extension makes the page easier to operate.