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 One Solution

Anais Cuvelier
Anais Cuvelier
2,184 Points

I do not understand what <span> is and why it was used in this case.

I've used <h3> for tittles and then <p> for the rest. After doing some research it said : "<span> is very much like a <div> element, but <div> is a block-level element whereas a <span> is an inline element." In that case why can't we use both times the <span> or the <p > ?

I hope my question make sense. Sorry I'm confused myself. :)

1 Answer

One reason I use the span tag is for semantic markup. For example, let's say you are making a job listing with html code and the position is part-time and you want to include that. The term "part-time" by itself isn't necessarily a paragraph... so semantically it doesn't make sense to use a <p> tag. In this instance I would use a <span> tag. Another reason to use a span tag would be to add specific styles to a short section of text within another paragraph. For example, you could do something like this... <p>This is a <span style="color:red;">warning</span></p> This way the word "warning" will have red text and the rest of the paragraph will be the default styling. Hope this helps.

Anais Cuvelier
Anais Cuvelier
2,184 Points

Hi Ryan, thank you for your answer! Yes it does help and it makes sense :)