Where’s my Background Image IE8?
Preamble/Rant
To say that I hate Internet Explorer would be an understatement. Quite simply, like many web designers/developers out there, I’ve wasted too many hours of precious time dealing with IE6 and fixing IE-related bugs for our relationship to be any other way.
Since I don’t like such feelings to be part of my life, a while ago I made the very healthy decision to stop supporting IE6 and IE7 in my projects. It’s something I would recommend to every web designer/developer, not only as a way to keep your mental sanity, but also in order to push – and thus educate* – people to upgrade to newer versions of Internet Explorer, or to better browsers altogether. Supporting obsolete browsers is like supporting a bad habit, and I’m done with that.
As Internet Explorer goes, that pretty much leaves me with just IE8 and IE9 to cater for, which is a walk in the park compared to the ugliness I had to deal with in the past.
Shall we bury the hatchet then?
Considering that I’ve just wasted two hours testing and scratching my head trying to solve a quite odd IE8 bug, I guess not. Not quite, yet.
To turn those two hours into something useful, I thought I’ll explain what the bug was and how I fixed it.
The issue
On a client project, I had assigned a tiled background image to the body tag. Pretty straightforward CSS, using the shorthand background property:
body {
background:#FFFFFF url(images/header-bg.gif) repeat-x 0 0;
}
The background image worked just fine on Firefox, Safari, Chrome and IE9, but was missing completely on IE8. To be honest, I had never heard of this IE8 issue with background images, nor had it ever happened to me before. Even stranger, the other background images in my CSS were all displaying correctly.
Possible causes & solutions
A syntax error
On most of the forum threads I checked, the problem seemed to be due to a syntax error: apparently, if you don’t put a space between the closing round bracket and the background-repeat value (in this case “repeat-x”), the background image won’t work in IE8 (while it still will on the other browsers). That’s good to know, although we should always use the correct syntax, regardless of the browser.
Being my syntax correct, there had to be another cause.
The image format?
Another possible cause that came up frequently in my search, was the image format. Some people had written they solved this issue by changing the background image from GIF/JPG to PNG. This doesn’t sound right to me. If IE ever had troubles with image format, PNG was surely the most problematic one and I don’t see why IE8 should have difficulties displaying GIFs or JPGs when even IE6 could (in fact, my other non-PNG background images were working just fine). For the sake of testing, I tried this solution anyway and – not surprisingly – it didn’t work.
So I wouldn’t say that the image format is a possible cause for this issue, but a wrong path to the image sure would be, so it’s good to first make sure that the image URL in your CSS is correct.
JQuery & Nivo Slider Script
Believe it or not, good old Javascript turned out to be the party pooper this time. Whenever possible, I always put my JS at the bottom of the markup, before the closing body tag, as it helps the page loading time. For some inexplicable reason, that caused the issue with my background image on IE8. Moving both the Nivo Slider and the JQuery script up to the head section made the trick: my long-gone background is now finally displaying ok on IE8, too.
I’ve only found one short thread about this background-image/javascript conflict on IE8 (and had to dig to find it) so I hope this article can help you save some time.
*Learn how to browse happy
This post is also available in Italian

22 Comments
Hi Oriana,
Thanks so much for this really interesting article!
I had this incredible background problem with IE8 (I hate IE, surprising no? LOL) and I found your thread: It was another script (with no relation with background) that conflicted with the background display.
So everything is fixed now… :)
Thanx again!
Cheers!
Hi Pascal,
I’m glad my article was helpful. Let’s keep up the fight! ; )
it helps me a lot… thank you very much
You’re welcome : )
Thank You…. Very Much…….
background:#FFFFFF url(images/header-bg.gif) repeat-x 0 0; its working in ie8………..
Thanks for posting your experience. My current dilemma: CSS is clean, HTML paths good, jQuery is in the head (though I am not using Nivo Slider) but still no background images in IE8 only.
Heres a test link, which is still being worked on so may continue changing.
Any other paths you might direct me to, I’ll be most appreciative.
HERE’S the link
http://www.lydiamann.com/TDB/MK/code/test-tabs.html
DO-OVERS! just after posting this I stumbled on a post about IE8 choking on HTML5 elements, i.e., header, article, etc. As soon as I removed that, all was good!
Hi Lydia, yeah, our “friend” IE8 also doesn’t support HTML5 elements. Rather than removing those elements, though, I’d recommend using the so-called HTML5 shiv, which is a very simple piece of JS that makes the new HTML5 elements visible to older versions of IE. This way we force IE8 to catch up rather than going backward to please it! : )
It may work if you use this DOC type
Hey Oriana can you help me out because i having facing this problem,
My website background image not working in ie8 but perfectly working to all other browsers.
Have a look to my css class :
.ongc-bg
{
background-image: url(‘../images/pattern.png’), url(‘../images/ongc-background.jpg’);
background-color: transparent;
background-repeat: repeat, no-repeat !important;
background-position: center center;
background-attachment: fixed;
-webkit-background-size: auto, cover;
-moz-background-size: auto, cover;
-o-background-size: auto, cover;
background-size: auto, cover;
}
In this class two background pictures coming simultaneously, the “pattern.png” will come up to the “ongc-background.jpg” image
I have tried all the stuffs mentioned above any of them not working for me.
Please help me…..
Thanks
Am using two url images in my body tag (in ie8 not working) any solution
@Rishabh and @Mr frank: IE8 doesn’t support multiple background images unfortunately (CSS3 support starts with IE9). If you really need both backgrounds in IE8 too, you’ll have to add an extra div after the body tag, and style that with your second bg image. Hope this helps!
Hi Oriana,
Thanks a ton ! you are a life saviour :)
NP! Glad I could help!
Thank you for posting this Oriana, in my case it was the syntax error :( . Im really glad I stumbled upon this. I was getting into “grrrrrrrr!” mode.
Ha! I know the feeling! Glad I could spare it for you this time!
Thank you, setting top and left to 0 for background image solved my issue.
you are the Woman Dear Oriana :)
Oriana RESCUE !!!! you are SUPER WOMAN :)
LOL, thank you Mehran! This is by far the most amusing blog comment I have ever received! : )
Thanks!!!! Adding a space after the closing round bracket worked for me. Windows XP support is going away by next year. When it goes so should IE8 support as well. Hopefully. Thanks again.
No problem Ray, I didn’t expect for my “rant” to help so many people but I’m glad it did! : )