Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
229,670 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.