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

CSS CSS Layout Basics Getting Started with CSS Layout Centering Page Content and Creating a Full-width Header

Barry Cherry
seal-mask
.a{fill-rule:evenodd;}techdegree
Barry Cherry
Front End Web Development Techdegree Student 3,395 Points

with the div container, why is the div put in as a child element to the <header> if we are going to edit the header?

If we are going to edit the header, shouldn't it have been:

                <div class="container">
                    <header class="main-header">
                       <h1 class="name"><a href="#">Best City Guide</a></h1>
                       <ul class="main-nav">
                        <li><a href="#">ice cream</a></li>
                        <li><a href="#">donuts</a></li>
                        <li><a href="#">tea</a></li>
                        <li><a href="#">coffee</a></li>
                    </ul>
                   </header>
                </div>

2 Answers

Steven Parker
Steven Parker
231,236 Points

The div inside provides a convenient target for styling to provide margins and centering for the inner elements, while still allowing the header itself cover the full width of the window.