Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the third value in CSS padding?

Tags:

css

I am playing around with the Less Framework 3 and I saw this line in the css:

body {     padding: 60px 42px 0;     width: 396px; } 

what does padding: 0 do?

This does not look like normal css shorthand, and top-right-bottom seems weird.

like image 291
tabaluga Avatar asked Jan 24 '11 16:01

tabaluga


People also ask

What is the order of padding in CSS?

When three values are specified, the first padding applies to the top, the second to the right and left, the third to the bottom. When four values are specified, the paddings apply to the top, right, bottom, and left in that order (clockwise).

What is the value of padding?

The padding property in CSS defines the innermost portion of the box model, creating space around an element's content, inside of any defined margins and/or borders. Padding values are set using lengths or percentages, and cannot accept negative values. The initial, or default, value for all padding properties is 0 .

What is padding give example?

Padding is a term used to describe the process of filling a field with pad characters. For example, if a name field required ten characters and your name was "Bob" (3 characters) the field would be "Bob0000000" where the 0's are the padding characters. 2.


2 Answers

The padding and margin properties specify top right bottom left.
If left is omitted, it will default to right.

Thus, padding: a b c is equivalent to padding: a b c b.

If bottom is also omitted, it will default to top.
Thus, padding: a b is equivalent to padding: a b a b.

If right is also omitted, the single value is used for all 4 sides.
Thus, padding: a is equivalent to padding: a a a a.

like image 101
SLaks Avatar answered Sep 18 '22 11:09

SLaks


When you specify three values the second is implicitly used for the fourth, i.e. padding: 60px 42px 0 42px;

like image 22
CAFxX Avatar answered Sep 19 '22 11:09

CAFxX