Proprietà paddingLeft
- Pagina precedente paddingBottom
- Pagina successiva paddingRight
- Torna alla pagina precedente Oggetto Style HTML DOM
定义和用法
paddingLeft
Definition and usage
paddingLeft Sets or returns the left inner padding of the element. padding-left attribute margin attribute
and
All 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.Padding interno CSS
See also:CSS Tutorial:
CSS Reference Manual:padding-left attribute
HTML DOM Reference Manual:
Padding property
Example
Example 1
Set the left inner padding of the <div> element:
Example 2
Change the left inner padding of the <div> element back to "normal":
Example 3
Returns the left inner padding of the <div> element:
alert(document.getElementById("myDiv").style.paddingLeft);
Example 4
Difference between marginLeft and paddingLeft:
function changeMargin() { document.getElementById("myDiv").style.marginLeft = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingLeft = "100px"; }
Syntax
Return paddingLeft property:
object.style.paddingLeft
Set paddingLeft property:
object.style.paddingLeft = "%|length|initial|inherit"
Attribute value
Value | Description |
---|---|
% | Defined by the percentage of the parent element's width to define the left inner padding. |
length | Defined by length units to define the left 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 left 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 paddingBottom
- Pagina successiva paddingRight
- Torna alla pagina precedente Oggetto Style HTML DOM