Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
A wrapper is commonly used to center a layout on the page. The wrapper keeps a layout from looking too wide or too narrow depending on the device or viewport width. This video covers two common ways to create a wrapper in your layout.
Video review
- Giving the wrapper a width prevents the layout from stretching too wide.
- Setting the left and right margins to the value
auto
centers the wrapper in the browser.
- One advantage to using
<body>
as the wrapper is that you donβt have to add an extra<div>
in your markup to contain your layout. - If you want to give your page a full background color or image, you'll need to apply it to the
<html>
element, and you can't place any elements outside of the<body>
.
- Using a wrapper
<div>
is more appropriate if your site has elements that need to be placed outside the wrapper.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up