473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

problem with BODY tag in firefox

Plater
7,872 Expert 4TB
I'm having a bit of trouble getting firefox to colorize my page.
I have for example:
Expand|Select|Wrap|Line Numbers
  1. body { background-color:red; color:white; }
  2.  
In IE6 this makes my page red. In Firefox it only makes the area where there is text red.
How can I force firefox to make the entire background red?
Jul 20 '07 #1
6 2887
Banfa
9,065 Expert Mod 8TB
I think that should work, which suggests may be an error elsewhere.

Generally I always start my CSS with something like

Expand|Select|Wrap|Line Numbers
  1. html,body{
  2.   margin: 0;
  3.   padding: 0;
  4.   font-size: 100%;
  5.   background-color: #F8FDD1;
  6. }
  7.  
Which normally has the desired effect on the background colour in all browsers.

I do not have access to firefox since I am at work but I suggest you take a browser through the DOM to see which rules are being applied to the areas in error and what the result is.
Jul 20 '07 #2
Plater
7,872 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. html,body{
  2.   margin: 0;
  3.   padding: 0;
  4.   font-size: 100%;
  5.   background-color: #F8FDD1;
  6. }
  7.  
Well it seemed a bit silly to me, but changing my body to html,body did the trick. Not sure why it wasn't applying to the body object, but all well
Jul 20 '07 #3
drhowarddrfine
7,435 Expert 4TB
In IE6 this makes my page red. In Firefox it only makes the area where there is text red.
In modern browsers, that is, not IE, html and body are seperate elements, but, in any case, the body should expand to fit the screen. This is a bug, among millions of others, in IE.

The reason adding html makes the whole background change color is because html is always the full browser viewport while body may not be and can be adjusted. body only expands to contain its contents. Firefox, again, is behaving correctly and per the standards. IE is not.

Banfa,
Why do you do "font-size:100%"? font-size is always 100% unless it's changed elsewhere.
Jul 21 '07 #4
Plater
7,872 Expert 4TB
Ah, see I always thought that since everything visible must go between the BODY tags, that it was representative of the whole page. No matter, adding that second bit made both of them work correctly.
Jul 23 '07 #5
Banfa
9,065 Expert Mod 8TB
Banfa,
Why do you do "font-size:100%"? font-size is always 100% unless it's changed elsewhere.
Well I may be a little out of date on this point but research seems to suggest that when using proportional font sizes (em, %, ex to name a few) the various browsers from various makers do not always seem to produce the same result for the same value.

Setting the font-size to 100%, which should be the CSS font-size equivalent of the assignment 1 = 1, actually reduces these effects.

This stems from the days of IE5, FireBird, Opera 6 and Netscape 6 so may my inclusion of it may well be a legacy thing now-a-days.

Setting the margin and padding also stems from those days where the different browsers variously put margins or paddings on the html or body tag to create the default margin.

The posted CSS is what I used to create as level a playing field as possible cross browser to start from.
Jul 23 '07 #6
drhowarddrfine
7,435 Expert 4TB
The margin/padding thing is perfectly valid, though there are new ways to "reset CSS" as it's called now. The only potential problem with using 100% is it becomes 100% of its parent, and if you size the parent, it can throw things off.

I need to write an article about resetting CSS.
Jul 23 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: fuzzyman | last post by:
I have a very odd problem that has boggled my head. I've been trying to get a 2 column layout working with CSS. The problem seems to occur with the use of the <script> tag in the document. I've...
6
by: R. Rajesh Jeba Anbiah | last post by:
In IE, I could be able to directly refer the "id", but it isn't possible in Firefox. Somewhere I read the solution is to refer the id like document.getElementById("month") in Firefox. If I do so,...
1
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the...
6
by: NoCopy na | last post by:
Using the following example: domiframetest.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
8
by: fuzzyman | last post by:
I have a very odd problem that has boggled my head. I've been trying to get a 2 column layout working with CSS. The problem seems to occur with the use of the <script> tag in the document, not the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.