Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Forms Organizing Forms The Label Element

Michael Bran
Michael Bran
1,687 Points

Is there any reason why simply using an h tag to do this wouldnt work just as well? <h3>Name:</h3>

Just wondering if there is some reason to use label over h3 (or any H)? What are the advantages or disadvantages to different approaches?

Edit: I understand you can "click" the label, but if you have to click, you might as well click the form box itself since thats where you have to type. I've never clicked labels in 20+ years of using computers, only ever in the box. Is this normal user behavior? Plus there must be a way to auto-focus the cursor which would be the most user friendly for devices without a mouse, though I have no clue how that would be done.

2 Answers

Kevin Gates
Kevin Gates
14,855 Points

Accessibility. Labels are used in conjunction with inputs and therefore provide onscreen assistance for those who need it. Headers are more like brief summaries of the next section of content.

Gabriel Pierce-Lackey
Gabriel Pierce-Lackey
11,014 Points

I think one of the main draws of labels over headers is that you can attach or group a label with an input using the for attribute, vs having to do more work than you need to do to group them together.