
You’ve created this really great design and everything looks just like the treatment the client approved in all other standards compliant browsers, but then they come back and say “By the way, it has to work in Internet Explorer 6 as well.” Great, here comes hours of debugging and a separate style sheet on top of that. And what are you supposed to do about all those 24bit PNGs with transparency you’ve used?
I have tried several solutions like using the AlphaImageLoader filter in an IE6 specific style sheet, TwinHelix’s IE PNG Fix, Unit Interactive’s Unit PNG Fix and a number of others, but none of the fixes worked for every situation. These solutions worked well except when used with background-position, background-repeat and elements with the a:hover pseudo-class.
DD_belatedPNG, written by Drew Diller, is a Javascript library that uses Microsoft’s implementation of VML (Vector Markup Language) instead of Microsoft’s AlphaImageLoader filter. It works by adding a line of CSS to the document via the DOM which acts as a MSIE-proprietary behavior (Javascript expression) that gets bound to the elements on the fly.

I’ve used it on a number of sites and have found that transparent images used with background-position, background-repeat and a:hover behave and display identically to modern browsers.

Implementing the fix is pretty straightforward, albeit you’ll want to use a conditional comment to keep other browsers from loading unnecessary code.
</body> tag.DD_belatedPNG.fix()('.class'), DOM element ('a, div, ul') or even a group of selectors ('.class, .class-two, #id').
<!--[if IE 6]>
<script type="text/javascript" src="DD_belatedPNG.js"></script>
<script>
DD_belatedPNG.fix('your_argument');
</script>
<![endif]-->

I would caution against just using DOM elements as this triggers the fix() for every reference of the element in the HTML document, including elements that do not contain transparent PNGs. If you do decide to use them, absolutely do not use ('body') as an argument. Just don’t, Chicken Little, the sky is falling, the whole bad enchilada.
There are still a few issues, like <tr>, <td> and <input type="image"/> not working, but for the most part this is the best solution to transparent images in IE6 that I have found to date.

Discussion
Great article. I have just used this fix for a clients site too after spending what felt like an eternity looking for the best solution.
Update: I have had a problem with IE6&7 when using a 1×1 pixel background. It slows right down and hogs all memory.
Peter, try using a 10×10 or 100×100 image instead. I’ve had success by increasing the dimensions of the image. Again the solution isn’t perfect, but it’s the best I’ve found so far.
I increased it to a 2×2 image, which fixed a seperate jQuery FadeIn & FadeOut error. I will try it again with a larger size. Do you know if IE tries to render them all individually, which would explain the problem
Try 4×4 – I don’t remember why (it’s been YEARS) but some friends and I determined that’s as small as you can go.
IE6 is dead, but if you do decide to support it, then I prefer the .htc method.
I used the .htc method for a number of years, but found that due to having to edit the .htc file to point to the pixel.gif using an absolute path that it was not ideal in some circumstances. IE6 unfortunately is still around to some degree and clients do still ask me to support it, so I prefer the above method as it’s much simpler to implement.
Great, thanks! BTW, you can forward your clients to the official funeral of IE6 here http://ie6funeral.com/
Thanks for leaving the thousandth comment on CreativityDen Robine
nice other transparency fix. but we are all wasteing time optimizing for IE6. Add your bill here http://billforbill.com
Leave a comment