HowDoiJava HowDoiJava - 1 year ago 87
CSS Question

CSS: Understanding the padding statement

I am trying to wrap my head around the padding statement - I've seen a few uses of it that makes sense to me, but recently I came across this implementation:

padding: 30px 0;

Now I understand the first parameter, 30px, but what does the 0 represent?

Thanks in advance!

Answer Source

padding is a shorthand property of

  • padding-top
  • padding-right
  • padding-bottom
  • padding-left

It allows multiple values:

If there is only one component value, it applies to all sides. If there are two values, the top and bottom paddings are set to the first value and the right and left paddings are set to the second. If there are three values, the top is set to the first value, the left and right are set to the second, and the bottom is set to the third. If there are four values, they apply to the top, right, bottom, and left, respectively.

Therefore, padding: 30px 0 sets padding-top and padding-bottom to 30px, and padding-right and padding-left to 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download