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
Sandro Meschiari18,418 Points
div and section
what is the difference between the section and the div? and when can i use them? can i put a div inside of a section or viceversa? Thank you for your help
There is absolutely no difference between the two, except their name. Other elements like
aside, and probably a couple more that I'm forgetting. Again, these all behave identically to each other and to
div; it's just their names that are different.
The different names make reading and understanding HTML a lot easier, because instead of using
divs everywhere, we can use
nav elements for navigation, or
header elements for headers, or
aside elements for sidebars or something similar.
You might use
section to separate blocks of content from each other. For instance, if I'm working on my blog's homepage, and I want to display my 10 most recent posts there, I might put each post inside its own
section. Inside that, I might use a
div to display my post title.
Hope that helps!
Charlie Jaime17,351 Points
If you like my answer vote me up, or mark me as the best answer. Thank you and great coding!