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 CSS Basics (2014) The Box Model The Box Model Review

Shirantha Mendis
Shirantha Mendis
1,228 Points

what is the answer for this ?When we use the margin value , the browser automatically calculates the margins for

what is the answer for this ? box model review

When we use the margin value ,________ the browser automatically calculates the margins for each side.

2 Answers

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

used like this

//short version
//top+bottom and left+right
div{
    margin: 0 auto;
}

//medium version
//top right bottom left
div{
    margin: 0 auto 0 auto;
}

//long version
div{
    margin-top: 0;
    margin: bottom: 0;
    margin-left: auto;
    margin-right: auto;
}

auto