Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html element background color not showing in IE 8

I'm using the <body> tag as a wrapper for three divs on a site where every single background color is white.

I've set the background color to #fff for the html and body in the css, and the site is rendering correctly in every browser (including IE 6 and 7) except IE8:

Only one of the divs (the central content) is displaying its background color

I've even tried setting the style for html directly inline like so: <html style="background-color: #fff"> but that doesn't seem to change anything.

Not even sure what might be causing the bug.

like image 576
Donald Jenkins Avatar asked Mar 17 '11 21:03

Donald Jenkins


2 Answers

The problem is the following property in your CSS:

:focus{
  outline:0;
  background-color:#f2f3f6;
  border-color:#996
}

Apparently, on loading IE8 decides that the html element has focus, whereas other browsers don't do this. Remove the background-color property here and it'll all stay white.

like image 172
Stephan Muller Avatar answered Oct 02 '22 07:10

Stephan Muller


What happens when you insert this code into your HTML?

body div
{
  background-color: white !important;
}

Normally, browsers interpret and apply the last line of CSS that they read to an element, so background-color: red; background-color: blue; would result in a blue background color.

!important tell the browser to ignore all other property re-decelerations, so background-color: red !important; background-color: blue; would make the background color red, even though you told it to be blue.

like image 27
Blender Avatar answered Oct 02 '22 05:10

Blender