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 Radio Buttons

Paula Mourad
Paula Mourad
5,154 Points

Labels vs Paragraphs

Hi!

Why do you use "labels" instead of a "p"? For example, in the radio button, instead of creating a label that says "Over 13 or older", can you just have a <p>Over 13 or Older</p>?

Thanks! :)

2 Answers

Belve Marks
Belve Marks
7,332 Points

Brendon is on the right track, but HTML should also be semantic. Meaning that the tags you use should express their function in the document. The <label> tag is just that, while the p tag is just a text dump. This not only makes the HTML easier to understand, but also makes it easier to style: instead of creating a classed <p>, you can simply target <label> in the CSS.

Brendon Butler
Brendon Butler
4,254 Points

I don't know for sure, since I never really use forms. But I think the reason being is that -- for one, paragraph tags have formatting pre-defined, where as with the label tag, you're essentially left with raw text (I could be wrong with this). Also, with labels you can define what css attribute it is linked to.

Source: HTML label tag

Paula Mourad
Paula Mourad
5,154 Points

Thanks Brendon :)