Deutsch | English | Español | Français |
Italiano | 日本語 | 한국어 | Português |
Pусский | 简体中文 | 繁體中文 |
Sets or retrieves the amount of space to insert between the left border of the object and the content.
![]() ![]() |
Syntax
padding-left:
<length>
|
<percentage>
Property values
- length
-
Floating-point number, followed by an absolute units designator (
cm
,mm
,in
,pt
, orpc
) or a relative units designator (em
,ex
, orpx
). For more information about the supported length units, see CSS Values and Units Reference. - percentage
-
Integer, followed by a percent sign (%). The value is a percentage of the width of the parent object.
CSS information
Applies To | All elements |
---|---|
Media | visual |
Inherited | no |
Initial Value | 0 |
Standards information
- CSS 2.1, Section 5.5.9
Remarks
As of Microsoft Internet Explorer 5.5, this property applies to inline elements. With earlier versions of Windows Internet Explorer, inline elements must have an absolute position or layout to use this property. Element layout is set by providing a value for the height property or the width property.
Negative values are not allowed.
Examples
The following example shows two div elements that each contain text and have specified width and border values. The second div element also has a specified padding-left value.
<div id="noPadding">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</div>
<div id="paddingLeft">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</div>
#noPadding {
width: 200px;
border: .5em solid #BBBBBB;
}
#paddingLeft {
width: 200px;
border: .5em solid #BBBBBB;
padding-left: 20px;
}
The following image shows the first div element without any padding.
The following image shows the second div element with a padding-left value of 20 pixels.
See also
- CSSStyleDeclaration
- currentStyle
- defaults
- runtimeStyle
- style
- CSS Enhancements in Internet Explorer 6