Style paddingTop Property
- Previous Page paddingRight
- Next Page pageBreakAfter
- Go to the Previous Level HTML DOM Style Object
Definition and Usage
paddingTop
Property sets or returns the top inner padding of the element.
The inner padding property defines the space between the element's border and its content.
margin Property and Padding Property Both insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See Also:
CSS Tutorial:CSS Padding
CSS Reference Manual:padding-top Property
HTML DOM Reference Manual:Padding Property
Instance
Example 1
Set the top inner padding of the <div> element:
document.getElementById("myDiv").style.paddingTop = "50px";
Example 2
Reset the top inner padding of the <div> element to "normal":
document.getElementById("myDiv").style.paddingTop = "0px";
Example 3
Returns the top inner padding of the <div> element:
alert(document.getElementById("myDiv").style.paddingTop);
Example 4
Difference between marginTop and paddingTop:
function changeMargin() { document.getElementById("myDiv").style.marginTop = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingTop = "100px"; }
Syntax
Return paddingTop property:
object.style.paddingTop
Set paddingTop property:
object.style.paddingTop = "%|length|initial|inherit"
Property Value
Value | Description |
---|---|
% | Defined by the percentage of the parent element's width for the top inner padding. |
length | Defined by length units for the top inner padding. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default Value: | 0 |
---|---|
Return Value: | A string representing the top inner padding of the element. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page paddingRight
- Next Page pageBreakAfter
- Go to the Previous Level HTML DOM Style Object