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 Selectors Selectors - Beyond the Basics DRY CSS

Shahar Golan
Shahar Golan
819 Points

margin: 0 auto 2em;

What the 0 and the "auto means?

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Shahar,

When using the margin shorthand property with 3 values, they represent the following:

margin: top left/right bottom;

Regarding your question, the zero simply means that you are removing the margin from the top of the element.

"Auto", means the browser will automatically calculate the value for the left and right margins. This is particularly useful when you want to center a block level element inside it's container.

Hope this helps.