Warning: Undefined array key "StartingPoint" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 107 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 115 Warning: Undefined variable $WEB_ROOT in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 169 CSS Tutorial - Positioning - padding
padding:1em;
padding-left:2em;
padding-right:20px;
padding-top:10px;
padding-bottom:4em;

Padding affects the area of a box or inline element, between the content of that element, and the border (visible or not). Effect: This will keep the content in distance to the edges of the element, like text in a div will not sit right on the border, but keep distance. Padding does not affect the size of the border, but it does affect the space that the element takes up in the page.

(Style in bold)
<div style="border:solid red 2px; ">
This is a div with some text in it, and a border of two pixels width.
</div>
<img alt="sample pic" src="nash.jpg" style="border:solid red 2px; " />
This is a div with some text in it, and a border of two pixels width.
sample pic

One can see how the content sits right on the edge of the border, which (like with the image) might be welcomed, but definitely text sitting so close to the border is not nice. For that we use padding: That will push the content away from the border.

(Style in bold)
<div style="border:solid red 2px; padding:1em; ">
This is a div with some text in it, and a border of two pixels width.
</div>
<img alt="sample pic" src="nash.jpg" style="border:solid red 2px; padding:1em; " />
This is a div with some text in it, and a border of two pixels width.
sample pic

The property padding: will result in a gap between border and content, on all four sides, the same length.
But one can also address each side on its own:

(Style in bold)
<div style="border:solid red 2px; padding-top:1em; ">
This is a div with some text in it, and a border of two pixels width.
</div>
<img alt="sample pic" src="nash.jpg" style="border:solid red 2px; padding-left:20px; padding-right:20px; " />
This is a div with some text in it, and a border of two pixels width.
sample pic