Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting rid of default page margins using CSS in Mozilla1 and Opera6.05...

    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
    redhead

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply brothercake, i'll see what else gets said.
    redhead

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    html, body {
    margin: 0;
    padding: 0;
    }

    Always works for me.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks jkd that sorted it
    redhead

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •