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
robert1
605 PointsWhen to use "section" in an HTML document instead of using "div"?
I learned a new HTML5 tag called "section", but I noticed that in the video we wrap "section" inside a "div". Couldn't the same thing work with "section class='sidebar'", for example instead of wrapping it all into a div?
4 Answers
Iago Wandalsen Prates
21,699 PointsOk, he used that div to put the section AND the footer into a single block. The div is being used for the sole purpose of centering the section and the footer. If you didnt have a wrapper div, you'd have to center both the main content and the footer, each at a time. It could work, but you would be repeating code, and more prone to errors, besides if you decide that you want the content to be smaller, you`d have to change it in more places. Does that answer you?
Iago Wandalsen Prates
21,699 PointsI don't really know which video you are referring to, as you didn't post relato to any, but divs are generally used when no semantic context applies, that usually means, for styling purposes only. If you can apply the visual effects with a single block element, that makes sense semantically, you should do it.
robert1
605 PointsThis was the video that mentioned wrapping "section" into a "div"
http://teamtreehouse.com/library/how-to-make-a-website/css-cascading-style-sheets/use-id-selectors
robert1
605 PointsAh, I understand now. Thank you very much!