What do you think of when you read or hear the term “transparency” in a web related conversations?
.png might be some peoples answer. “UGH!”, could be a common answer also. If you go to my website you’ll notice some ink splatter headers that sit throughout the design. I had quite a hard time getting those to display correctly thanks to Internet Explorers lack of native png transparency support. It is one of THE most complained about topics on the web (and I have done my fair share of it). People have been asking for the support since BEFORE version 5.0 but today, there are still a lot of hacks and “fixes”, it shouldn’t be that hard to use transparency.
Here’s an example of a browser that supports png transparency, and IEs lack of it.
Market Share - The reason it is such a hugely discussed topic is because IE has over 75% of the browser market share. (between versions 6 and 7) Check it out:

That is a huge amount! It would probably be safe to say that everyone who owns a PC and is not working in the web industry is using Internet Explorer to browse websites. With the exception of those handful of people related to somebody that works in this industry, hah!
These are some, but not all of the workarounds, new ways are being created frequently but these are the ones we will explain below.
I ran into this fix for png transparency when I was developing my site. It is probably one of the easiest fixes out there to get working. All you need is a blank .gif image and to initiate the script via your stylesheet:
Example - initiating iepngfix.htc script
img{ behavior: url(iepngfix.htc); } /* or you can target specific elements and their backgrounds /* #header{ width: 800px; height: 200px; background: url(path/to/image.png); behavior: url(iepngfix.htc); }
Of course this is considered a “hack” and it has some limitations to it
For more on this method you can go to TwinHelix.com or straight to his demo page
Ahh, jquery. I find jquery as one of (if not THE) best javascript library out there. I found this fix while working on some admin panels for Buffini & Company. With the jquery.ifixpng plugin you can replace all the images on the page or you can target certain elements on the page. For this fix you will need a blank or one pixel gif, Jquery and of course the ifixpng plugin
Example - applying filters to .png for correct ie6 display
$(document).ready(function() { // apply to all images $(’img[@src$=.png]’).ifixpng(); // apply to target elements $(’img[@src$=.png], div#header’).ifixpng(); });
This fix also has its limitations
for more on this method checkout the demo page
If you’re feeling lazy, or don’t want to use any scripts to add the filter you can do it manually. Be wary if you decide to use it on repeating backgrounds, it will make any text un-selectable and any links un-clickable in the target element.
Example - applying AlphaImageLoader
#header{ width: 800px; height: 200px; background: url(path/to/image.png); filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src= path/to/image.png',sizingMethod='crop'); }
You can read up on all the parameters of the filter on the Microsoft site.
There are some beautiful sites on the web right now using transparent elements in their design and you should check them out for some great inspiration.
The fixes mentioned above aren’t as good as native transparency support, but they work and that’s what counts. If you have other methods or would like to mention a good site using transparency please comment below and share with us.
See more posts under: Resources, Tips & Tweaks
OR see posts tagged with: compatability | png | transparency
You may also like:
OR follow on Twitter
Twitter.com/DeDestruct
Comments
I normally try and stay away from .pngs - instead I use .gifs.
I just make sure I know what background my image will be on and set the matte to the right color.
But that’s just me.
Like you’re blog btw.
I just recently found it and I’m excited to be following it. You seem to have some great content here!
I can’t remember how I found it though…
this is also a nice solution (not as nice as native support, of course):
.element{
/* Mozilla ignores crazy MS image filters, so it will skip the following */
//filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src=’images/image.png‘);
}
/* IE ignores styles with [attributes], so it will skip the following. */
.element[class]{
background: url(images/image.png) no-repeat center center;
}
there is a common problem that transparent png’s flicker in IE when used in conjunction with hyperlinks where the background changes, or when the background image changes position. for this you can use a simple line of javascript in the of your page:
try { document.execCommand( “BackgroundImageCache”, false, true); } catch(e) {};
it forces IE to cache the background image instead of reloading it on hover.
Nice one!
I would also recommend Mr Dean Edwards script: http://dean.edwards.name/IE7/
The amoutn of times I’ve used it is countless
Dean Edwards for president!
A far easier solution is to use fireworks.
Open your image with a transparency in fireworks. In the top right corner with the color wheel choose PNG 8. Then choose alpha transparency(as opposed to no transparency). Then file->export the image as a png file.
What will happen is browsers that don’t support that alpha transparency will operate like index transparency while browsers that do will render the image with the alpha transparency giving you a nice soft edge.
Two of the sites i’ve done it for work are santashotline.com and santaclaus.net. In both examples check out the logos on ie6 or older and on an alpha mask supporting browser.
Enjoy!
Have you tried supersleight.js. It is a new version of the bgsleight.js released long time ago. I is now reborn into a super version much like superman.
Check it out on http://www.24ways.org/
This version works for repeated background compared to any other versions or hack I’ve tried before…
here is a simple way to fix this. After setting the background filter in IE, set all of the links to position:relative. That will fix it AND it will work in all browsers.
see http://reignwaterdesigns.com/ad/tidbits/hacks/ie_png_fix.shtml for a really good and simple example.
Cheers!
There are many “z-index” issues (links not clickable) when applying filters. To get rid of most of them (unless you don’t put png32 background on top of other png32 backgrounds…), here are 2 simple rules :
1. Don’t position your filtered element! You can’t use position:absolute or position:relative in conjonction with the filter. If you need to position it, add a wrapper around, position the wrapper and then apply the filter on your inner element.
2. Like Addam said, position the links, but you can position one container and everything contained in it will be clickable (don’t forget the first rule ;-))
And a last funny thing about filters, if you apply it directly on an anchor element, it will create a “click mask”, the transparent zones are not clickable, while the opaque ones are! Like if you had created an imagemap.
Enjoy!
Thibaut Allender’s last blog post… Reactable - Powered by CommentLuv
Koivi made a nice PNGfix using PHP. Advantage of this method is that the server does some browsersniffing and returns the correct html (with alphaImageLoader-stuff added) depending on the browser.
It’s not as easy to integrate as the behavior-solutions, but it’s definitely more solid and doesn’t show grey parts when the site isn’t completely loaded before a behavior is triggered.
You can check it out at:
http://koivi.com/ie-png-transparency/
PNG has me up and down. I don’t know what really to do anymore. Sometimes it work but more often that not it conflicts with something else. All told… IE 6 must just die. Really. It has limited designers in so many ways it is tiresome.
I hate microsoft cus they endorse the products so.
Foxinni - Wordpress Designer’s last blog post… Cheat Sheet Cheat Sheet? - Powered by CommentLuv
Read jimbabwe’s post about Fireworks png!
I thought: “no, it can’t be that simple” ….. and spent a day and a half trying various PHP, javascript & CSS fixes on my Photoshop pngs.
You know what? I needn’t have bothered
Jimbabwe is right, right, right!!!
Thanks for the tips, i had tried so many png hacks which haunted me for couple of days trying to fixing a web that I’m currently doing which involves heavy usage of transparent png image format and it looks ugly in IE6. But most of the hack failed, but the only hack that works the most is Supersleight.js by 24ways, but it still broken somewhere.
i really want to dump IE6 (the site looks great in FF2, IE7 and Safari), but still has a lot of ppl use IE6, :(. Totally agree with Foxinni though, IE6 just make me so tired.
All IE PNG fixes i have come across are really bullshits & of no use..
i simply exclude IE when it comes to transparent PNG images…I use them no matter what happens in IE..we should neglect the f**king IE…
I found this script on dynamic forums and it fixes multiple PNG files on the page in ie6, so you don’t have to add the code to single images.
I hope this helps someone:
http://www.pockitz.co.uk/js/correct_png_fix.js
Cheers
Pockitz
Thanks for the post. There are certainly many work-arounds for this, and I don’t think I’m happy with the choices at the moment. I’ll be writing about this issue at some point I think.
Thanks for this. Big help for me, was looking for alternative to the alpha loader. TY, TY, TY!!!!
Here’s and idea for you all. (Note, this will not work for all occasions based on your design but for most.) Instead of using js to solve your problems, why not try IE conditional comments? What do I mean you say? The solution is relatively easy. Just save your image as gif/jpg and apply the proper path in your IE6 CSS and apply a conditional comment. Now, in your standard compliant CSS for all other modern browsers, have your pngs plugged in. voila!
This post is old but you should now check Drew Diller’s DD_belatedPNG, the ultimate PNG fix for IE6.
Thibaut Allender’s last blog post… Lofts polonais – Adaptation of Former Granary - Powered by CommentLuv
Trackbacks
Leave a reply