Sent by Liorean on 26 May 2002 14:02
At 12:42 2002-05-26 -0400, Joshua Prowse wrote:
>According to the specs, is one supposed to apply the following styles to the
><body> or the <html> element?
>- margin, padding
>- background
The specs have nicely handled this for us, by stating that background
values on body are to be transformed into background values on html when no
different background settings exist on html element. The safest way of
doing it is a "html, body {background:<insert background value here>;}".
As for the padding and margin (and border even if you didn't mention it),
there's some things to take into account as for what element to apply them to.
>Also, what are the default margins and padding in a document? I think that
>documents have a margin and padding:0px; but it could be the other way
>around -
>I don't know. I usually use:
>
>html, body {margin:0px;padding:0px;}
>
>However, I'm sure that's redundant in some respect and that I cant shorten
>that.
Now, most browsers use the wrong value, and use the margin of the body
element. So "body {margin:0px;}" is a good start. Then some browsers use
the padding value on the html element, so "html {padding:0px;}" is the
second rule to add. Third, some browsers use the padding value of body
element, so "body {padding0px;}" is the last thing to add. Those taken
together is what you write, though the px unit is not necessary on zero
values, I think, so you could write "html,body{padding:0;margin:0;}".
Now, have a look at this:
<http://www20.brinkster.com/liorean/tests/boxdoc/>
If you use IE6 or Moz you'll notice all four of them look a bit
differently. If you use Opera you'll find it is consistent as to whether it
has a doctype or not. I believe IE Mac, Konqueror and the rest would
provide you with their own differences between them. And on top of those
differences within the browsers, you'll find the browsers don't agree very
much with eachother in any case.
I believe the doctype one with the box rules will be the one most
consistent on modern browsers (Read: IE6, IE Mac, Moz/Ns7, Op6, Konq and
not much more).
// Liorean