If, for example, I have a div that encompasses a whole section of my page with a background colour that differs from the background colour of my <body>, and then there is a div INSIDE that div with NO background, why does the nested div show the <body> background colour (instead of the div behind it) in Firefox, but not in IE? I've found a workaround - place a "footer" that clears everything INSIDE the outer div, but this seems kludgy. Suggestions?
post your css/html code or a link to the site... i just tried out nested divs and its working fine in firefox,maybe theres something wrong with your code, and you mentioned clearing everything by footer, so i am guessing it MAY be a float problem...
Here's an example: http://www.memorizingpi.com/cssexample.php CSS is at http://www.memorizingpi.com/cssexample.css
wow, i worked on the file and its like magic, the colors are all different even when i remove background property from all except body, its shows me outerdiv lightblue, column1 pale orange, and column 2 pale purple.... bg is dark grey.... im not exactly sure but setting doctype declarations will deal with the problem
Ok, first off PART of IE's behavior is correct. There is no float on the "Ok, we're inside" text - floats are display:block inherently so the 'column 1' SHOULD appear below that text. BUT, IE wrapping the entire thing is the INCORRECT behavior - non-floating containers by the specification are NOT supposed to expand to contain floats. Both of your div's are floating, so the outer box shouldn't expand. This is a well documented and common issue I often have to code around... though MOST of the time that is in fact the behavior I want in all browsers. To make other browsers do what IE is doing in terms of stretching the container, you can make the outer container float, or set overflow:hidden or overflow:auto... Problem with the float is, well, sometimes you want 100% with padding which you can't do with float... the problem with overflow being if you need to set haslayout, height won't auto-switch to auto. I guess the question becomes which behavior do you WANT? IE style or RoW (Rest of World)