CSS padding-left attribute
- Previous page padding-inline-start
- Next Page padding-right
Definition and Usage
The paddingLeft property sets the left inline padding (whitespace) of the element.
Description
This property sets the width of the element's left inline padding. The left inline padding set on inline non-replaced elements only appears on the left side of the first inline box generated by the element.
Note:Negative values are not allowed.
See Also:
CSS Tutorial:CSS Padding
HTML DOM Reference Manual:paddingLeft Property
Example
Set the left inline padding of the p element:
p { padding-left:2cm; }
(More examples can be found at the bottom of the page)
CSS Syntax
padding-left: length|initial|inherit;
Property Value
Value | Description |
---|---|
length | Specifies a fixed left inline padding value in specific units, such as pixels, centimeters, etc. The default value is 0px. |
% | Defines a percentage left inline padding based on the parent element's width. This value does not work as expected in all browsers. |
inherit | Specifies that the left inline padding should be inherited from the parent element. |
Technical Details
Default Value: | 0 |
---|---|
Inheritance: | no |
Version: | CSS1 |
JavaScript Syntax: | object.style.paddingLeft="10px" |
Try It Yourself Example
- Set left inline padding 1
- This example demonstrates how to set the left inline padding of a cell using centimeter values.
- Set left inline padding 2
- This example demonstrates how to set the left inline padding of a cell using percentage values.
Browser support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | IE / Edge | Firefox | Safari | Opera |
---|---|---|---|---|
1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
- Previous page padding-inline-start
- Next Page padding-right