Set the top padding of a <div> element:
The paddingTop property sets or returns the top padding of an element.
The padding properties define the space between the element border and the element content.
Both the margin property and the padding property insert space around an element. However, the difference is that margin inserts the space around the border, while padding inserts the space within the border of an element.
The paddingTop property is supported in all major browsers.
Return the paddingTop property:
Set the paddingTop property:
Value | Description |
---|---|
% | Defines the top padding in % of the width of the parent element |
length | Defines the top padding in length units |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | 0 |
---|---|
Return Value: | A String, representing the top padding of an element |
CSS Version | CSS1 |
Change the top padding of a <div> element back to "normal":
Return the top padding of a <div> element:
Difference between marginTop and paddingTop:
CSS tutorial: CSS Padding
CSS reference: padding-top property
HTML DOM reference: padding property