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

Andrew Smith
Andrew Smith
14,330 Points

Why use a wrapper div for styling when the body element can be used for the same purpose?

A brief search yielded advice that was either "a wrapper div is usually unnecessary" or "a wrapper div can be useful to prevent style conflicts with overlays and is useful in fixed width, centered designs". The latter piece of advice did not elaborate on why the body element is not always suitable for fixed width, centered designs, however.

On a related note, how do you add additional tags to questions? I'd like to link this question to the video I was watching on the "Accessibility Course" in the Front-End Development Track.

1 Answer

Colin Marshall
Colin Marshall
32,861 Points

If your design is fixed width or centered, you will need a wrapper that acts as a container for the design. You can't set a width for the body. Think of the body as always being the entire window, no matter what size your browser window is. Therefore, if you need a fixed width layout, you need to put a wrapper div inside the body so you can set the width and margins of the wrapper to make the layout fixed width and centered.

As for your 2nd question, you cannot add in the tags to the post. To have your post tagged with the video you are on, you need to click the button link under the video titled "Ask a question." On code challenges, the same link is in the right sidebar.

Andrew Smith
Andrew Smith
14,330 Points

Thank you for your clear and succinct answer.