Margin vs. Padding

Tihomir R. Todorov

Version 1
Copyright © 2009 Tihomir R. Todorov
20091115_2103_115.11.2009Tihomir R. Todorov
Article created.


1. Sundries
2. CSS Syntax

1. Sundries

CSS provides two properties named margin and padding for keeping space between HTML Box type elements.

So, if we want that the text begins 3px from the left edge of the containing element, padding would be the right choise.

2. CSS Syntax

Example:      is equal to     
   body {    body {
     margin:   1em 1em 1em 1em;      margin:   1em;
     padding: 0px   0pt   0em 0;      padding: 0;
   }    }

We can use also:
margin-top, margin-right, margin-bottom, margin-left
padding-top, padding-right, ...