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

CSS CSS Basics (2014) Basic Selectors Descendant Selectors

Parker Arbuthnot
Parker Arbuthnot
1,969 Points

What does the "Span" element do?

I am confused to what the Span element does. If someone could go in-depth, explaining what it did, it would be extremely helpful! Thanks!

2 Answers

The span tag is like the div tag. It has no meaning at all and is mostly used for styling by using an id or class. The difference between the two is that div is a block element, It's on a seperate line. span however is an inline element, meaning that it can be on a line with other elements.

Personally, I use span to style text inside div or any other elements. For example:

<div class="game">Orioles <span>Vs</span> Yankees</div>

Now I can target the span inside the .game and style it.

Parker Arbuthnot
Parker Arbuthnot
1,969 Points

Oh!! Okay, thank you so much!

Omar Jimenez
Omar Jimenez
1,446 Points

Groups text for styling purposes. It is a inline element which means it sets within a line of text.