RE: margin vs. padding

>> is there any preference for one of them on the Body tag in CSS ??

> I think padding makes more sense, but I don't know what's preferred.

That depends on whether you consider the "body" to encompass the entire
window. Currently, that is always the case, but what if a web page were
inserted into another page (say, an SVG page)? Then the margins might make
more sense.

Actually, both make sense even now, but you wouldn't know that from the way
body is implemented. What would make the most sense would be this:

body { background: red; margin: 10px; padding: 10px; }

Assuming the browsers default background color is white, there should be a
10px white band around the page. The body content would then sit 10px
further inside the red area. Make sense?

I tested this in Opera, IE, and Netscape and none of them showed a white
border. Evidently, body is identified with the window itself. I don't see
any reason it must be...

Charles F. Munat,
Seattle, Washington

Received on Wednesday, 17 January 2001 22:49:22 UTC