CSS padding-left
property defines the padding for the left side of an element. The padding-left is the space between the content and the left border of an element.
The padding-left property can be specified in any valid CSS length formats such as โpxโ, โemโ, โremโ, โcmโ, etc. It can also be specified using percentage(%). It does not accept negative values.
Example:
.p1{ padding-left: 40px; } .p2{ padding-left: 4em; } .p3{ padding-left: 20%; }
CSS Syntax
The padding-left
property has the following syntax:
padding-left: length|percentage|initial|inherit;
Property Values
The padding-left
property accepts the following values:
length | Sets a fixed left padding in CSS length formats such as โpxโ, โemโ, โremโ, โcmโ, etc. The default value is zero. |
percentage | Sets left padding in percentage. The percentage value is calculated by taking the percentage of the elementโs width itself. |
initial | Sets the padding-left property to its default value(0). |
inherit | Inherits the padding-left property from the parent element. |
General Info
Default Value | 0 |
Inherited | No |
JavaScript Usage | element.style.paddingLeft = โ40pxโ |