- From: Alexander Savenkov <w3@hotbox.ru>
- Date: Sat, 20 Apr 2002 00:50:03 +0400
- To: "Nigel Peck" <Nigel.Peck@itm-solutions.co.uk>
- CC: www-html@w3.org
Hello again,
> Please could someone tell me the correct way to remove the margin from
> a page using CSS.
> I am currently using;
> BODY {margin: 0 px;}
> which works for IE but not NS.
> P.S. I have also tried {padding: 0 px;}
Although Nigel haven't mentioned his Netscape version I assume it is
version 4.x, the buggiest piece of code on Earth.
Anyway if you want to have a clean CSS solution without NS-specific
tag attributes you may need the following (sorry for the copyright -
I was very happy when that finally worked in NS4):
/* nav4 margin hack (C) Alexander Savenkov mailto:w3@hotbox.ru */
html, body { margin: 0px } /* what I wanted it to be */
body { margin: -10px } /* what I have to do to remove the uglyness /*
@media screen { /* NS4 can't see inside @media rules */
body { margin: 0px } } /* but the clever UAs are aware of them */
/* nav4 margin hack end */
This won't completely remove the margins but will result in some
interesting effects which are helpful in most cases.
I used this solution at http://idefence.da.ru/. There are margins
around the page in my NS4, but the absolute positioned elements are
at their appropriate places. The absolute position is calculated
relatively to the page contents (like if there were no margins).
Internet Explorer obviously displays the page correctly. So does
Opera.
Another opportunity to remove the margins is:
html, body { margin: 0px; position: absolute; top: 0px; left: 0px }
or even
html, body { margin: 0px; position: absolute; top: 0px; left:
0px; bottom: 0px; right: 0px }
I had no chance to test this on my Netscape 4 because it immediately
died with "The program performed illegal operation..." I only know
that this may result in some problems with scripts.
Hope this helps.
Best regards.
---
Alexander "Croll" Savenkov http://www.thecroll.com/
w3@hotbox.ru http://croll.da.ru/
Received on Friday, 19 April 2002 16:50:54 UTC