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 trialPeter Tomasiewicz
5,592 PointsWhy additionally wrap things in a div class="container" if they are already wrapped in the header class="main-header" ?
From what I understand, HTML elements such as header, section, footer, etc are divs. If so, why does Guil add this extra 'div layer' to wrap the contents of the header? Definitely more to type but is there an advantage to doing this in this particular case ?
2 Answers
Sebastian Röder
13,878 PointsIn the video he mentions that he wants all containers to be the same width and have the same margin, so that the content does not run to wide e.g. on large screens. He wants to add the CSS rules to archive this to the container class later. You could copy and paste the same rules into the main-header, section, footer etc. classes manually, but since you can add as many classes as you want to your HTML elements is makes sense to bundle all those rules in a separate class, in this case called container.
In real life examples, if you ever wonder what a div with a certain class or id does, you can always "View Source" in your web browser and inspect the CSS rules for that class or id.
Peter Tomasiewicz
5,592 PointsThanks Sebastian, that totally makes sense !
Sebastian Röder
13,878 PointsThanks Peter. I reposted my comment as an answer below.