Style paddingLeft attribute
- Previous Page paddingBottom
- Next Page paddingRight
- Go to the Previous Level HTML DOM Style Object
定义和用法
paddingLeft
Definition and Usage
paddingLeft Sets or returns the left inner padding of an element. padding-left Property margin Property
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.CSS Inner Padding
See Also:CSS Tutorial:
CSS Reference Manual:padding-left Property
HTML DOM Reference Manual:
Padding Property
Instance
Example 1
Set the left inner padding of the <div> element:
Example 2
Set 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"
Property Value
Value | Description |
---|---|
% | Defined by the percentage of the parent element's width for the left inner padding. |
length | Defined by length units for 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 |
Support | Support | Support | Support | Support |
- Previous Page paddingBottom
- Next Page paddingRight
- Go to the Previous Level HTML DOM Style Object