Style paddingLeft Property

Style Object Reference Style Object


Set the left padding of a <div> element:

document.getElementById("myDiv").style.paddingLeft = "50px";

Try it yourself »

Definition and Usage

The paddingLeft property sets or returns the left padding of an element.

Both the margin property and the padding property insert space around an element. However, the difference is that margin inserts the space around the border, while padding inserts the space within the border of an element.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The paddingLeft property is supported in all major browsers.


Return the paddingLeft property:

Set the paddingLeft property:"%|length|initial|inherit"

Property Values

Value Description
% Defines the left padding in % of the width of the parent element
length Defines the left padding in length units
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Technical Details

Default Value: 0
Return Value: A String, representing the left padding of an element
CSS Version CSS1

More Examples


Change the left padding of a <div> element back to "normal":

document.getElementById("myDiv").style.paddingLeft = "0px";

Try it yourself »


Return the left padding of a <div> element:


Try it yourself »


Difference between marginLeft and paddingLeft:

function changeMargin() {
    document.getElementById("myDiv").style.marginLeft = "100px";

function changePadding() {
    document.getElementById("myDiv2").style.paddingLeft = "100px";

Try it yourself »

Related Pages

CSS tutorial: CSS Padding

CSS reference: padding-left property

HTML DOM reference: padding property

Style Object Reference Style Object


Color Picker