Propriedade de espaçamento superior do estilo
- Página anterior paddingRight
- Próxima página pageBreakAfter
- Voltar à página anterior Objeto Style do HTML DOM
Definição 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 all insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space within the element's border.
See also:
CSS Tutorial:Margem interna do 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 the paddingTop property:
object.style.paddingTop
Set the paddingTop property:
object.style.paddingTop = "%|length|initial|inherit"
Property value
Value | Description |
---|---|
% | Define the top inner padding as a percentage of the parent element's width. |
length | Define the top inner padding with a length unit. |
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 |
Suporte | Suporte | Suporte | Suporte | Suporte |
- Página anterior paddingRight
- Próxima página pageBreakAfter
- Voltar à página anterior Objeto Style do HTML DOM