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

CSS Reference Manual

CSS @rules (RULES)

Comprehensive List of CSS Properties

CSS padding-right attribute usage method and example

padding-The right CSS attribute sets padding to the right, that is, the space between the right border and the content of the element. However, in many cases, the shorthand shorthand CSS attributepaddingEasier to use and more desirable.

The following table provides the usage instructions and version history of this attribute, as well as the usage 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
An animatable property:Yes.Please refer to Animation Attribute.
Version:CSS 1,2,3
JavaScript Syntax:object.style.paddingRight="5em"

padding-right attribute syntax usage

The syntax of this attribute is as follows:

padding-right: length | percentage | initial | inherit

The following examples demonstrate how to use padding-right attribute.

  h1 {
   padding-right: 2em;
  }
  p {
   padding-right: 50px;
  }
Test to 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 adopts the padding of its parent element.-right attribute values.

Browser Compatibility

padding-Browser Compatibility of the right attribute; the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1+

  • Opera 4+

Read More

Please refer to the following tutorial:CSS Padding.

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