Padding Properties






PropertyDescriptionPossible ValuesExamples
padding-topDeclares the top padding for the element.Lengths, percentages, and the predefined value .
div { padding-top:5px; }

div { padding-top:15%; }

padding-rightDeclares the right padding for the element.Lengths, percentages, and the predefined value .
div { padding-right:5px; }

div { padding-right:15%; }

padding-bottomDeclares the bottom padding for the element.Lengths, percentages, and the predefined value .
div { padding-bottom:5px; }

div { padding-bottom:15%; }

padding-leftDeclares the left padding for the element.Lengths, percentages, and the predefined value .
div { padding-left:5px; }

div { padding-left:15%; }

paddingShorthand property used to declare all the margin properties at once.Separate values by a space in the following order (those that are not defined will use inherited or default initial values):

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

Undeclared values work as further shorthand notation. If only one length value is declared, all four sides will use that length. If two lengths are declared, the top and bottom sides will use the first length while the right and left sides will use the second length. If three lengths are declared, the top side will use the first length, the right and left sides will use the second length, and the bottom side will use the third length.

div { padding:5px 12px 4px 7px; }

div { padding:5px; }

div { padding:5px 10px; }

div { padding:5px 7px 4px; }



Back to Learn More About CSS