padding-right - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding-right

Description

The padding-right CSS property sets the padding to the right side.

Padding is the amount of space between the right border and the content of an element.

The following table summarizes the padding-right Property.

Item Value
Default value: 0
Applies to:All elements except <tbody>, <thead>, <tfoot>, <tr>, <colgroup> and <col>. It also applies to ::first-letter.
Inherited: No
Animatable: Yes.

Syntax

The syntax of the property is as follows:


padding-right:      length | percentage | initial | inherit

Property Values

The following table describes the values of this property.

Value Description
length Set the padding as a length value in px, pt, cm, em, etc. Negative length values are not allowed.
percentage Set the padding in percentage which is calculated with respect to the width of the element's containing block. Negative percentage values are not allowed.
initialSets this property to its default value.
inherittake the value of its parent element padding-right property.

The example below shows the padding-right property.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS padding-right property</title>
  <style type="text/css">
    h1 {<!--from   ww w.  j  a  v a 2  s . com-->
      padding-right: 2em;
      background: #ffb6c1;
    }
    p {
      padding-right: 50px;
      background: #f0e68c;
    }
    </style>
 </head>
 <body>
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
 </body>
</html>

Related Tutorials