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 trialReuven Kishon
5,270 PointsWhy do we use <span> to insert the numbers 1 and 2 within the legend of the fieldsets?
Is there any particular reason, or are there other ways to achieve this that may be better? Some ways I can think of are:
1) Use a <p> or <div> element with a class of "number", instead of <span>
3) Use an h1, h2, h3, etc and target it more specifically in the CSS via a descendant selector such as:
legend h1 (or h2, h3, etc) {}
4) Or for that matter, user an h1, h2, h3 with a class of "number", then target it via a descedant class selector such as:
legend h1 (or h2, h3, etc).number{}
1 Answer
egaratkaoroprat
16,630 Points<div> and <span> both have no (semantic) meanings. While <div> is used to wrap things i.e. acting as a container, the <span> tag is used for inline content. So, if you would use a <h1> instead of a <span>, then not only it will take its own line, it also add a heading 1 to the document which might not be appropriate. Thus, it makes <span> more flexible as you can add it 'anywhere' to an existing content.
I hope this answers your question, otherwise let me know what might be still unclear to you.