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

HTML

Why section and footer elements were wrapped in a div having an id "wrapper"?

Hi

In the "how to make a website" course, Nick Pettit wrapped the section and footer element inside a div having an id "wrapper". I couldn't understand the purpose of wrapping the section and footer element inside a div.

Can anybody tell me, why he did so?

2 Answers

Wrapping the entire webpage content that resides within in the Body element inside a separate Div tag is a commonly used design technique which can help position the content to a more presentable and readable location if you don't intend to take up the entire full width of the browser, such as in the center.

By doing this it also gives you the freedom to have a different background style, such as colour or perhaps an transparent image. Sometimes you'll the divs called "container", "alpha_container", "wrap" or something to that effect. As you progress further through the course and other courses this will become more clear as to why with practice and examples.

that way the content can be given a width and centred whilst still keeping a different colour background. The more divs you have, the more precise control you have over each item on the page.