Consider you have a div with fixed height and weight (in the drawing the innermost one), and you want the surrounding divs to contain it, with an out margin of e.g. 1 em. How would you do that?
+--------+
| +-----+|
| |+---+||
| || |||
| |+---+||
| +-----+|
+--------+
One way is to use the
inline-blockdisplay style:For this HTML:
Here’s an example: http://jsfiddle.net/redler/zSrXA/
You can also try playing with
display: table-cell.