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 Basics Images, Text and Links Add Meaning to Words with Text Level Elements

Tierra Butler
Tierra Butler
634 Points

I still don't understand the purpose of div or span

<div> <span>

4 Answers

Kieran Barker
Kieran Barker
15,028 Points

They’re generic block- and -inline level containers, respectively, to be used when a more semantic element is inappropriate. If you’re only grouping elements together for the sake of styling, for example, rather than for semantic reasons.

Already have a good explanation, but let me try breaking it down a little. when you use a div element, it forces other elements to go beneath it, taking up the entire space which is referred to as Block level container. while a span does not forces element to go beneath it and does not take up entire space, it only takes up as much space as needed and is referred to as Inline level Containers. You will likely use a span when you want to span a particular group without breaking the styling into new lines.

Rico Suhanta
Rico Suhanta
831 Points

do you mean its a container to grouping purposes?

Tierra Butler
Tierra Butler
634 Points

ok makes sense thank you

Thank you was still confused since I learned <div>