padding-right
sets the width of the right padding for an element.
Item | Value |
---|---|
Initial value | 0 |
Inherited | No. |
Version | CSS1 |
JavaScript syntax | object.style.paddingRight="2px" |
Applies to | All elements. |
padding-right: length | percentage | auto | inherit
The property values are listed in the following table.
Value | Description |
---|---|
auto | Default value. The browser does the calculation. |
length | Set width in px, cm, etc. |
% | Set width in percent of the containing element |
inherit | Inherit the width property from the parent element |
padding-right |
Yes | Yes | Yes | Yes | Yes |
An example showing how to use padding-right CSS property.
<!DOCTYPE HTML>
<html>
<head>
<style>
div {<!-- ww w.ja va 2 s . c o m-->
float: left;
background: gold;
margin: 5px;
width: 250px;
}
div div {
float: none;
background: white;
border: none;
font: 10px sans-serif;
color: rgb(200, 200, 200);
width: auto;
}
div#properties {
padding-top: 2px;
padding-right: 4px;
padding-bottom: 6px;
padding-left: 8px;
}
div#four-values { padding: 2px 4px 6px 8px; }
div#three-values { padding: 2px 8px 6px; }
div#two-values { padding: 2px 8px; }
div#one-value { padding: 2px; }
</style>
</head>
<body>
<div id='properties'>
<div>
Lorem ipsum dolor sit amet, consectetuer.
Nulla bibendum eros sit amet lectus. Nunc,
interdum ut, congue ut, scelerisque quis.
</div>
</div>
<div id='four-values'>
<div>
Lorem ipsum dolor sit amet, consectetuer.
Nulla bibendum eros sit amet lectus. Nunc,
interdum ut, congue ut, scelerisque quis.
</div>
</div>
<div id='three-values'>
<div>
Lorem ipsum dolor sit amet, consectetuer.
Nulla bibendum eros sit amet lectus. Nunc,
interdum ut, congue ut, scelerisque quis.
</div>
</div>
<div id='two-values'>
<div>
Lorem ipsum dolor sit amet, consectetuer.
Nulla bibendum eros sit amet lectus. Nunc,
interdum ut, congue ut, scelerisque quis.
</div>
</div>
<div id='one-value'>
<div>
Lorem ipsum dolor sit amet, consectetuer.
Nulla bibendum eros sit amet lectus. Nunc,
interdum ut, congue ut, scelerisque quis.
</div>
</div>
</body>
</html>