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

Linking "Labels" to which attribute?

Hello, when i use labels, am i linking it to "id" or to the "name"? For example: <label for="test">Test</label> <input type="checkbox" id="test">

or should it be

<label for="anothertest">another Test</label> <input type="checkbox" name="anothertest">

2 Answers

Agnes Demes
Agnes Demes
6,613 Points

Hi, labels need to be linked to the id

Jack Weldon
Jack Weldon
1,708 Points

Labels should be linked to the id. If you're unsure in future you can always check by trying both and seeing which one creates the desired result.