Forum Moderators: not2easy

Message Too Old, No Replies

Background-color for whole viewport?

Just using body tag leaves some white background

         

JayCee

4:35 am on Sep 16, 2004 (gmt 0)

10+ Year Member



Hi All,

My page is smaller than my viewport, for this fixed width CSS layout. Using "background-color" with the body tag takes care of coloring the page, but the space to the right of my page in the browser viewport is not colored.

Should i use background-color on the HTML tags to color everything?
Or what?

Thanks!

createErrorMsg

12:02 pm on Sep 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



background-coloring the HTML tag might work, but I've never heard of this sort of behavior before. I'm wondering if you have something in your code that is causing the browser not to fill the viewport with the body tag (like it should). An extra body tag, perhaps? Maybe the body is unclosed?

If you haven't already, you might want to run the html through the validator and see if there isn't an error that's causing this problem.

sonjay

12:55 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



Have you set margin:0 and padding:0 for body in your css sheet?

JayCee

3:06 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



Thanks, your help led me to the answer.
Yes, margins and padding are zero.

But, this page is based on a Dreamweaver MX 2004 template. In that template, there is a body style in the doc's head (because of a previous trick i no longer need). In the current doc, the body style is in the external sheet and there is no CSS in the head.

So efecctively, there were 2 conflicting body styles.
I'll disengage the problem doc from its template and make it a new template.

BTW there is advise online recommending against using the HTML tags for background-color. Seems not well supported cross-platform.

Also a CSS site suggested using "background: #nnnnnn;", instead of "background-color: #nnnnnn;". They said it was better supported, but don't know if this advise is old. Seems to work, i'll see if my validator complains.

Your help is much appreciated :)

sonjay

2:34 pm on Sep 17, 2004 (gmt 0)

10+ Year Member



Hmmm, I've always used background-color without a problem. So I Googled for info on that, and what I'm finding seems to indicate that background-color is not supported, or is buggy, in 4.x versions of Netscape. But apparently it's supported fine by all other browsers, and by more recent versions of Netscape.

If anyone has information on recent browsers that don't support background-color, I'd be interested in finding out which ones.

NN4 needs to die a horrible, painful death.

JayCee

2:56 pm on Sep 17, 2004 (gmt 0)

10+ Year Member



Actually, i thought i had a fix, but no.

Finally, i just created a "#page-background" div id that is just inside the whole HTML body tag and that works fine.