Set padding-top to 2px in HTML and CSS

Description

The following code shows how to set padding-top to 2px.

Example


<!--from w  w w  . ja  va2s . c  o  m-->







<html>
<head>
<title>padding</title>
<style rel='stylesheet' type='text/css'>
div {
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;
}
</style>
</head>
<body>
<div id='properties'>
<div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Nulla bibendum eros sit amet lectus. Nunc eros massa,
interdum ut, congue ut, scelerisque quis, tellus.
</div>
</div>

</body>
</html>

Click to view the demo

The code above generates the following result.

Set padding-top to 2px in HTML and CSS
Home »
  HTML CSS Tutorial »
    Layout »
      Padding
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
Set padding-left to 1cm and padding-right t...
Set padding-top to 2px in HTML and CSS