...

View Full Version : getting rid of default page margins using CSS in Mozilla1 and Opera6.05...



redhead
10-08-2002, 03:42 PM
Hello all.

I have a site which previously used 'marginwidth="0" marginheight="0" leftmargin="0" topmargin="0"' in the body tag of its pages to kill the default margins. I ran this through the validator at w3 and was suprised to see that this wasnt "valid"

wanting valid code, i took out the offending code and replaced it with "margin: 0px 0px 0px 0px" in the css... and it worked fine in IE6 and (suprisingly) in NS6....

but the default margins were present in Mozilla1 and Opera6.05...

any suggestions of a way to get rid of the borders using CSS that will work in Mozzila1 and Opera6.05?

thanks :thumbsup:

brothercake
10-08-2002, 04:51 PM
There isn't one. Or rather there is, because

<body style="margin:0px">

should work in Opera 6 - I've used it successfully before. But the problem arises if you want to do any scripting which uses obj.offsetLeft or obj.offsetTop properties - becuase in Opera 5 and 6 and also Mac/ie5 the offset position values do not take account of CSS margins at all - the value isn't readable in script and returns undefined.

So ... the bottom line is that the only reliable solution is to go back to your "traditional" way of doing it, and ignore the validator.

redhead
10-08-2002, 05:01 PM
thanks for the reply brothercake, i'll see what else gets said.

jkd
10-08-2002, 05:17 PM
html, body {
margin: 0;
padding: 0;
}

Always works for me.

redhead
10-08-2002, 05:39 PM
thanks jkd that sorted it :)

brothercake
10-08-2002, 06:15 PM
Originally posted by jkd
html, body {
margin: 0;
padding: 0;
}

Always works for me.


It does work, but is preblematic for the reason I mentioned; that's why I advised not using it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum