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 trialSimon Dein
4,772 PointsWhy not apply the "container-class" to the header-element itself?
Why create a new div to apply the contain/wrap instead of applying it to the header?
It makes sense to me in the content area of the page because we need to contain "alot" of elements, and we don't have any other way to go about it (other than applying the class to all elements nested inside...). But in the header we already got a unique containing/wrapping element for all the content - the header itself. So why create more markup just to apply the container/wrapper? I can see that by thinking a little forward it could be that in the future we would like to nest something in the header - but outside the wrapper of the header - other than that i can't think of anyt other reasons.
Any explanation/s (good practice, specific reasons etc) will be much appreciated! :)
2 Answers
Savannah Lynn
13,662 PointsExactly. Not every project in the future will be set up so simply. Some might contain a lot of content and columns in the header, and it is easiest to style those elements when they are all contained in a div element. Although the <header> tag can hold nested elements, it can't be styled in the same way a <div> can, or at least it's not best practice. Almost every site I have built in this track, I create a container div for the header/navigation, and one for the main content of the site, and sometimes one called wrapper or something that holds ALL of the site content if I want to give everything a particular background or layout.
Simon Dein
4,772 PointsThanks for your answer Savannah Smith - makes sense. I guess the more and more examples i see and try out myself, the more it will make sense! :)
PS. I realised i had a couple of grammatical errors that kinda made the question a little weird - sorry for that (english is not my main language).
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointschanged comment to answer