|
CSS padding properties define the space between the element border and the element content.
If four values are given, they apply to top, right, bottom, and left padding, respectively.
If one value is given, it applies to all sides. If two or three values are given, the missing values are taken from the opposite side.
Length Unit:
A length value is formed by an optional + or -, followed by a number, followed by a two-letter abbreviation that indicates the unit.
There are no spaces in a length value; e.g., 1.3 em is not a valid length value, but 1.3em is valid. A length of 0 does not require the two-letter unit identifier.
* em (ems, the height of the element's font)
* ex (x-height, the height of the letter "x")
* px (pixels, relative to the canvas resolution)
Percentage Unit:
A percentage value is formed by an optional + or -, followed by a number, followed by %. There are no spaces in a percentage value.
Percentage values are relative to other values, as defined for each property. Most often the percentage value is relative to the element's font size.
In CSS, to specify different padding for all sides:
Example css padding
padding-top:25px;
padding-bottom:25px;
padding-right:50px;
padding-left:50px;
|