Set padding-left to 1cm and padding-right to .5cm in HTML and CSS
Description
The following code shows how to set padding-left to 1cm and padding-right to .5cm.
Example
<!-- w ww . ja v a 2 s.c om-->
<html>
<head>
<title>HTML/XHTML: » CSS1 Padding Example</title>
<style type="text/CSS">
#one {border-style: double; border-width: medium; padding-left: 1cm; padding-right: .5cm;}
#two {border-style: double; border-width: medium; padding-top: 1cm; padding-bottom: 1cm;}
#three {border-style: double; border-width: medium; padding: 1cm 1cm; margin: .5cm 4cm;}
</style>
</head>
<body>
<div class="content">
<p id="one">This paragraph of text has padding on the left and
right, but not on the top and bottom.</p>
<p id="two">This paragraph has padding, but this time only on the
top and bottom.</p>
<p id="three">Be careful when using margins. They don't necessarily
apply to the text within the box, but to the box itself.</p>
</div>
</body>
</html>
The code above generates the following result.
HTML CSS Tutorial Padding
Combine negative text-indent and padding-le...
Compare padding, one value, two values, thr...
Demonstrate padding 0 is the default in HTM...
Demonstrate that the element's background i...
Do padding with em value in HTML and CSS
Set padding for four directions separately ...
Set padding-left to 0px for list in HTML an...
Set padding-left to 1.5em in HTML and CSS
Combine negative text-indent and padding-le...
Compare padding, one value, two values, thr...
Demonstrate padding 0 is the default in HTM...
Demonstrate that the element's background i...
Do padding with em value in HTML and CSS
Set padding for four directions separately ...
Set padding-left to 0px for list in HTML an...
Set padding-left to 1.5em in HTML and CSS