W3C home > Mailing lists > Public > www-style@w3.org > January 2001

Re: margin vs. padding

From: Chris Lilley <chris@w3.org>
Date: Thu, 18 Jan 2001 12:51:35 +0100
Message-ID: <3A66D8C7.78A6D52A@w3.org>
To: "Charles F. Munat" <chas@munat.com>
CC: "'fantasai'" <fantasai@escape.com>, www-style@w3.org


"Charles F. Munat" wrote:
> 
> >> 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.

Yes.

> 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, 

Why do you assume that and what CSS would you write in the UA stylesheet to
make it so?

> there should be a
> 10px white band around the page. The body content would then sit 10px
> further inside the red area. Make sense?

Not when the root element is html, no.

> 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...

http://www.w3.org/TR/REC-CSS2/colors.html#q2
  The background of the box generated by the root element covers 
  the entire canvas.
  For HTML documents, however, we recommend that authors specify 
  the background for the BODY element rather than the HTML 
  element. User agents should observe the following precedence 
  rules to fill in the background: if the value of the 
  'background' property for the HTML element is different 
  from 'transparent' then use it, else use the value of the 
  'background' property for the BODY element. If the resulting 
  value is 'transparent', the rendering is undefined. 

-- 
Chris
Received on Thursday, 18 January 2001 06:55:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:07 GMT