Posted by Jonathan N. Little on 05/05/06 17:56
Toby Inkster wrote:
> Michael Laplante wrote:
>
>> Is there any sort of design consideration that makes a designer choose one
>> over the other?
>
> padding is inside the box and will assume the same background as the rest
> of the box. margin is outside the box so has a transparent background,
> allowing the parent's background to show through.
>
Looking up padding and margin a w3.org first then a little
experimentation can go a long way...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Margin VS Padding</title>
<style type="text/css">
..bymargin, .bypadding {
border: 1px solid red;
color: black;
background-color: yellow;
}
..bymargin {
margin: 100px;
padding: 0;
}
..bypadding {
margin: 0;
padding: 100px;
}
</style>
</head>
<body>
<div class="bymargin">DIV by margin...</div>
<div class="bypadding">DIV by padding...</div>
</body>
</html>
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
[Back to original message]
|