English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete List of CSS Properties

CSS padding-left Attribute Usage and Example

padding-The left CSS attribute sets padding to the left, that is, the space between the left border and the content of the element. However, in many cases, the shorthand notation CSS attributepaddingMore commonly used and preferable.

The following table provides usage instructions and version history for this attribute, as well as the syntax of this attribute in JavaScript scripts.

Default Value:0
Applies To:All elements, except<tbody>,<thead>,<tfoot>,<tr>,<colgroup>and<col>. It also applies to::first-letter.
Inheritance:No
Can be animated:Yes.Please refer to Animation Attributes.
Version:CSS 1,2,3
JavaScript Syntax:object.style.paddingLeft="2em"

padding-left Attribute Syntax

The syntax of this attribute is as follows:

padding-left: length | percentage | initial | inherit

The following examples demonstrate how to use padding-left Attribute.

  h1 {
   padding-left: 2em;
  }
  p {
   padding-left: 50px;
  }
Test See‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
lengthValues in units such as px, pt, cm, em, etc., negative values are not allowed.
percentageSpecify percentage padding. The percentage is calculated relative to the width of the element's containing block. Negative percentage values are not allowed.
initialSet this attribute to its default value.
inheritIf specified, the associated element uses its parent element padding-The left Attribute Value.

Browser Compatibility

padding-Browser Compatibility of the left Attribute, the numbers in the following table indicate the minimum browser version that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1+

  • Opera 4+

Read More

See the following tutorials:CSS Padding,CSS Box Model.

Related Attributes:padding,padding-top,padding-right,padding-bottom.