Proprietà Style paddingTop
- Pagina precedente paddingRight
- Pagina successiva pageBreakAfter
- Torna al livello superiore Oggetto Style HTML DOM
Definizione e uso
paddingTop
Sets or returns the top inner padding of an element.
The inner padding property defines the space between the element's border and its content.
margin property and Padding property They both insert space around the element, but the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See also:
CSS Tutorial:Margine interno CSS
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
Change the top inner padding of the <div> element back to "normal":
document.getElementById("myDiv").style.paddingTop = "0px";
Example 3
Return 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 |
---|---|
% | Top inner padding is defined as a percentage of the parent element's width. |
length | Top inner padding is defined by length units. |
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 that represents the top inner padding of an element. |
CSS version: | CSS1 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto |
- Pagina precedente paddingRight
- Pagina successiva pageBreakAfter
- Torna al livello superiore Oggetto Style HTML DOM