By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,394 Members | 1,912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,394 IT Pros & Developers. It's quick & easy.

using position attribute in body element

P: n/a
Just out of curiosity, has anyone run into this problem? Someone where
I work put a set of pages together with the following in the style sheet:

BODY { position: absolute;
margin-top: 0mm;
margin-left: 0mm;
margin-right: 0mm;
border: 0mm;
padding: 0mm;
border-width: 0mm;
left: 0mm;
right: 0mm;
top: 0mm;
}
The page displays correctly for Netscape 4.7 and 7 as well as IE 6. The
problem is if you go to print the page up from Netscape 7. Only the first
page will print. I did a little experimenting and discovered that if you
remove "position: absolute;" from the body element, then Netscape 7 will
correctly print all pages.

I was wondering if there were some guidelines for how and when
"position: absolute;" should be used. I've typically only seen it used for
images, divisions or other sub elements within a body, not as part of
the body style. Frankly, I can't see what benefit it adds to the body
element.

--
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know
that will *run and hide* from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
na****@ctip5ei.ih.lucent.com (J. Potts) wrote:
Just out of curiosity, has anyone run into this problem? Someone where
I work put a set of pages together with the following in the style sheet:

BODY { position: absolute;
margin-top: 0mm;
margin-left: 0mm;
margin-right: 0mm;
border: 0mm;
padding: 0mm;
border-width: 0mm;
left: 0mm;
right: 0mm;
top: 0mm;
}
What a strange stylesheet.
mm are very rarely a useful unit on the web (marginally useful in
print stylesheets, totally useless in screen stylesheets).
Zero lengths don't need units at all.
There's no need to set margins, especially zero margins, on absolutely
positioned elements.
The page displays correctly for Netscape 4.7
Indeed. This hack is one way of getting rid of the default page
margins in NN4. For those people who still bother trying to make pages
pixel identical in NN4 and modern web browsers.
and 7 as well as IE 6. The
problem is if you go to print the page up from Netscape 7. Only the first
page will print. I did a little experimenting and discovered that if you
remove "position: absolute;" from the body element, then Netscape 7 will
correctly print all pages.
Hmm, I can sort of see what's happening. By setting position: absolute
on body you're attaching the body to the semi-mythical root element.
On screen this root element is the browser window (sort of, browsers
vary on how the relate the root element, the html element, the body
element and the browser window) but when printed the root element
could be the page. So maybe the body is being attached to the first
page and when it doesn't fit the excess is not printed on subsequent
pages. Or I may be talking out of my arse.
I was wondering if there were some guidelines for how and when
"position: absolute;" should be used. I've typically only seen it used for
images, divisions or other sub elements within a body, not as part of
the body style.
The best advice is that absolute positioning should be used with care.
Frankly, I can't see what benefit it adds to the body element.


Apart from the above mentioned NN4 hack there are also a few hacks
involving absolutely positioned bodies that work around shortcomings
in IE's CSS support (e.g. to simulate position: fixed;).

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.