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 How to Make a Website Styling Web Pages and Navigation Create a Horizontal List of Links

matthewroller
matthewroller
2,159 Points

How do I set a margin of zero to the top and bottom?

How do I set a margin of zero to the top and bottom of the page. Last I left off was top, right, bottom, left to set margins.

I thought the answer to this would be..

nav ul { margin: 0, 10px, 0, 10px; }

2 Answers

Stephanie Raumschuh
Stephanie Raumschuh
17,582 Points

No commas nav ul { margin: 0 10px 0 10px; }

Or you can use the shorthand version nav ul { margin: 0 10px; }

Clinton Hopgood
Clinton Hopgood
7,825 Points

I good way to think of it is like a clock, you start at the top and go clock wise.

nav ul {margin: 0} /* all sides */
nav ul {margin: 0 10px} /* margin 0 top and bottom and margin 10px left and right*/
nav ul {margin: 0 10px 0 10px} /* Same as the one above but each side set */