Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 11:39 PM
J. Potts
Guest
 
Posts: n/a
Default using position attribute in body element

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
  #2  
Old July 20th, 2005, 11:39 PM
Steve Pugh
Guest
 
Posts: n/a
Default Re: using position attribute in body element

navoff@ctip5ei.ih.lucent.com (J. Potts) wrote:
[color=blue]
>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;
> }[/color]

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.
[color=blue]
>The page displays correctly for Netscape 4.7[/color]

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.
[color=blue]
>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.[/color]

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.
[color=blue]
>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.[/color]

The best advice is that absolute positioning should be used with care.
[color=blue]
>Frankly, I can't see what benefit it adds to the body element.[/color]

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 <steve@pugh.net> <http://steve.pugh.net/>
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles