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 trialPaula Mourad
5,154 PointsLabels 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
7,332 PointsBrendon 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
4,254 PointsI 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
5,154 PointsThanks Brendon :)