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
Johan Rönkkö
28,054 PointsElements and classes
What are the CSS-perks of first having a element and give it a class, then inside the element give it a wrapping div with a similar class? Example:
<header class="main-header">
<div class="header-inner">
</div>
</header>
1 Answer
Simon Gray
10,507 PointsHi Johan,
One advantage is that you could give the "header-inner" div a max-width while allowing the outer div's background to cover the entire page width. It's a good idea to constrain the width of content on larger viewport size's to make it easier to read.
You wouldn't necessarily have to add a class to your header div, that would depend on the rest of your CSS.
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsHi Johan,
I added markdown to make the html visible. If you're curious about how to add markdown like this on your own, checkout this thread on posting code to the forum . Also, there is a link at the bottom called Markdown Cheatsheet that gives a brief overview of how to add markdown to your posts.
Cheers!