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

body or #wrapper.

Why use a #wrapper when one can use the body element to accomplish the same thing?

2 Answers

Vance Rivera
Vance Rivera
18,322 Points

It is probably best to use a wrapper element and not the body as a wrapper. This is because it will make your life as the developer easier to control and manipulate elements and sections in your layout. You should use the wrapper to contain most elements in your html to make sure you have proper alignment for all of your information. Furthermore you should also use sections within your wrapper as well. Sections will help you distinguish and group information and elements within the wrapper. So for instance you can have a header, navigation, content, and footer sections. To go a little deeper with each section you can also make even more distinguishing parts to your layout. For instance in your content section you can make a left column, middle column, and right column. All of this the wrapper element, sections, and columns provide the same service for the layout and that is to section off elements for the purpose of information flow and aesthetics.

Domen Stojic
Domen Stojic
31,376 Points

If you have simple website with only one mayor item in a body; you could do without a wrapper, but if you create a more complex site with many elements, then you need a #wrapper simply because you want things to happen inside it, that should stay contained inside it.

You could use body with many wrapper type labels or you could use a section label to differentiate them better.

You should just try it out yourself and experiment with CSS and you will understand it better!