Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy.
OK
Specifies a shorthand property for setting the top, right, bottom and left spaces between an element's border and its contents, in that order.
The padding property is nearly equivalent to the margin property, both insert space around the element.
But while margin inserts the space around, padding inserts it within the border of the element.
In other words, the padding property specifies the distance between the border and the element's content.
JavaScript page for this property: padding. You can find other example(s) there.
Possible values:
One of the following values:
This value can be used from 1 to 4 times (use the space character to separate them)
Takes the value of this property from the computed style of the parent element.
space in non-negative length
The space in length units. For the supported length units, see the length page.
space in non-negative percentage
The space is the specified percentage of the width of the parent element.
Default: this property has no default value.
If only onepadding value is set, it is used for all four sides.
If twopadding values are specified, the first value is used for the top and bottom sides, the second one is for the left and right sides.
If threepadding values are set, the first value is used for the top side, the second one is for the left and right sides and the third one is for the bottom side.
If fourpadding values are specified, the order is top, right, bottom, left (clockwise from top).
Example HTML code 1:
This example illustrates the use of the padding, border and margin properties: