Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML How to Make a Website Adding Pages to a Website Add Iconography

Steve Isaacs
Steve Isaacs
2,112 Points

Why are the Margin and Padding shorthand numbers different in the example?

The correct code in this challenge shows this for padding and margin:

 padding: 0 0 0 30px;
 margin: 0 0 10px;

But why does padding show four values and margin show three? Aren't they both trying to show just a value for the bottom? I'm confused.

2 Answers

Hi Steve,

This question here is linking to the video so I'm not sure if you're referring to that or a code challenge afterwards.

The 10px for the margin value is for the bottom but the 30px padding value is for the left side, not the bottom. This is to make room on the left for the icons.

4 values:

1st value is for top then it goes in a clockwise direction around the box. top, right, bottom, left

3 values:

1st value is top, 2nd value is both left and right, 3rd value is bottom.

2 values:

1st value is top and bottom, 2nd value is left and right.

1 value:

All 4 sides get that value.

Steve Isaacs
Steve Isaacs
2,112 Points

Ahhh ok. Got it. Thanks again, Jason.