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

JavaScript Interactive Web Pages with JavaScript Selecting Elements and Adding Events with JavaScript Plan

Kerstyn Comley
Kerstyn Comley
2,996 Points

Why is 'Add Item' specified as a label?

A little off topic, this is about HTML rather than JavaScript. In this project there are three headings:

Add Item Todo Completed

Todo & Completed are both specified in the HTML as <h3> but 'Add Item' is a <label>. Why has the designer chosen to do this?

Hi Kerstyn Comley, just letting you know I formatted your question to escape the HTML characters so they will display properly.

2 Answers

A label can only be attached to/associated with one form input.

For Todo and Completed, they have potentially multiple inputs (the checkboxes), so each input needs its own label.

For Add Item, the text field is the only input, and it still should have a label, so I guess they chose to use the heading and style it the same.

Gonzalo Blasco
Gonzalo Blasco
11,927 Points

I guess it's 'cause using a label specified to the input instead of just text let you select the input just by clicking it.