PNG Transparency in Internet Explorer

code.gifI teach a Multimedia class at Plymouth State University. This week we were discussing the pros and cons on the use of PNGs. I mentioned that Internet Explorer versions 6 and lower fail to render the transparency of a PNG properly, placing white background in the transparency’s place. I also took the time to plug Firefox, mentioning that Firefox does it right!

Well, one of my students, Brendan Emery sent along this fix for PNG transparency in Internet Explorer, thus refuting my biggest con on PNG use! (honestly, I can’t think of any other cons)

[This is] a JavaScript-based PNG fix for Internet Explorer 5.5 and 6 on Windows. The fix allows IE to properly render PNG alpha transparency. [...]

Why only versions 5.5 & 6? Because Windows IE versions prior to 5.5 do not support the filter which fixes the PNG problem, and version 7 (not yet released at the time of writing in January 2006) is reported to have fixed the issue entirely.

The code can be used either by a one-time copy-and-paste or as an include file. The entire thing is completely ignored by all other browsers - in fact it is treated as an HTML comment - thanks to IE’s conditional comments. This solution is therefore light, portable and non-invasive to other browsers.

Discuss This Article


14 Responses to “PNG Transparency in Internet Explorer”

  1. AvatarDeath_Tap

    You got pwned.

    Don’t fail me!

    Reply to this comment.
    1
  2. AvatarSEO Articles

    These Javascript fixes aren’t exactly ideal - and most solutions only fix img tags, not background pngs.
    Bah, wish we could just ignore IE.

    Reply to this comment.
    2
  3. AvatarTerrorBite

    …since when did backgrounds need transparency?

    It’s not like there’s anything behind a background.

    In that case, just convert to a non-transparent PNG.

    Also, it’s not all transparent PNGs that are affected - only the ones with alpha transparency. The ones with index transparency (like transparent GIFs) are fine. Which sucks.

    Reply to this comment.
    3
  4. AvatarTrevor

    TerrorBite:

    Background images need transparency when they are applied to elements intended to be viewed on top of (in the z-index) another element, or another background, or whatever. I can think of a million different ways to use that.

    Reply to this comment.
    4
  5. AvatarSuj

    Terrorbite, you talk rubbish :) If you have a container dv with a background image, then another over the top - with a transparent png background, you’ll have a nice opaque effect, uncovering slightly what’s beneath (the picture).

    Thats why background images could make use of transparency.

    Reply to this comment.
    5
  6. AvatarJD

    As a deisgner I wish that IE could be removed from every computer and replaced with Firefox. How come everyone else even open source handle PNG, but IE can’t find the time to fix it over the last 6 years.

    Reply to this comment.
    6
  7. AvatarSeoBlog

    Интересная статья ‘PNG-прозрачность в IE 5.5-6′: http://www.tigir.com/alpha_png.htm

    Reply to this comment.
    7
  8. AvatarFlorin

    Hi,

    Good fix, but how can I change it to support background png’s? I don’t need background-position or repeat-x(y), just


    experimentation revealed I could traverse the Stylesheets collection and use the AlphaImageLoader trick to replace all background-image attributes containing PNGs

    Reply to this comment.
    8
  9. Avatarstevo

    A very nice workaround. Thanks a lot

    Reply to this comment.
    9
  10. AvatarAndrew

    I have this working but the final output is still looking different in IE6. Despite me setting a width and height in the img style it looks bigger in IE6 and doesn’t look as crisp as it does in Firefox/IE7.

    Microsoft can go to hell!

    Reply to this comment.
    10
  11. AvatarCW

    I had the same result as Andrew, basically the “fix” could not be used because it distorts images.

    Reply to this comment.
    11
  12. Avatarogłoszenia

    Thanks a lot for this workaround!

    Reply to this comment.
    12
  13. AvatarNero

    It doesn’t work for me. I need a transparent background which I set using CSS. Stupid IE.

    Reply to this comment.
    13
  14. Avataralec

    Thank you so much for this fix. It saved me sooo much time.

    Reply to this comment.
    14

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment Preview:

 (12833) - ie6 transparency (212) - png 24 ie6 (54) - png24 ie6 (46) - transparent png ie6 (40) - fix png ie6 (33) - png 24 ie (25) - png ie6 fix (21) - png ie6 (19) - transparency ie6 (18) - javascript PNG IE6 (16) - PNG-24 ie6 (16) - ie6 transparency problem (16) - ie fix png (15) - ie png background fix (15) - ie6 png background (15) - transparent png in ie6 (14) - background png ie6 (13) - transparent png on ie6 (13) - ie png fix background (12) - transparency (11) - PNG IE background (11) - transparent png firefox (10) - ie png background (10) - png ie6 background (10) - png background ie6 (9) - PNG ie6 transparency (9) - ie6 png transparency (9) - png fix background (9) - png-24 in ie6 (9) - png background fix ie (8) - png fix ie6 background (8) - png transparente Ie6 (7) - ie png transparency fix (7) - ie6 png-24 (7) - png (7) - png transparent ie6 (7) - ie6 background png (7) - png 24 fix (6) - fix png ie (6) - Transparent PNG background IE fix (6) - png background ie fix (6) - png ie fix (6) - ie6 png 24 (6) - transparent png ie firefox (6) - png background explorer (6) - ie png fix (5) - fix png in ie6 (5) - png24 ie (5) - transparent png ie6 fix (5) - png background fix ie6 (5) - javascript IE6 png (5) - transparency in IE (5) - IE6 transparency issue (5) - png transparency fix for IE6 (5) - fix PNG background (5) - png 24 ie6 fix (5) - png transparency in IE (5) - transparency in IE6 (5) - png ie6 javascript (5) - ie background png fix (5) - PNG 24 and IE6 (4) - png 24 transparency (4) - ie6 png javascript (4) - ie6 transparency support (4) - HACK explorer 6 BACKGROUND PNG (4) - прозрачность png ie6 (4) - PNG transparency IE fix (4) - png 24 ie 6 (4) - png 24 in ie6 (4) - png background fix (4) - PNG-24 IE (4) - explorer png support (4) - IE png hack (4) - png transparency in IE6 (4) - ie6 fix png (4) - png for ie6 (4) - ie opacity png background (4) - javascript png support in ie6 (4) - ie6 png transparent background (4) - explorer png graphics (3) - how to png-24 in IE6 (3) - png 24 explorer (3) - Прозрачность png в Internet Explorer (3) - png 24 support IE6 (3) - png 24 ie fix (3) - transparence png ie (3) - ie6 png прозрачность (3) - png-24 internet explorer (3) - background png fix (3) - png background ie6 fix (3) - ie6 png js (3) - png background fix for IE (3) - прозрачность png internet explorer (3) - png-24 ie fix (3) - ie6 png hack (3) - png 24 on IE6 (3) - js for png in ie6 (3) - IE6 transparency issues (3) - fix background png (3) - ie png 24 (3) - ie6 png transparency fix (3) - png transparency firefox (3) - why png 24 perfect in internet explorer (3) - ie png transparency (3) - internet explorer png (3) - fix ie png (3) - png IE transparency (3) - fix PNG for IE (3) - png ie firefox (3) - png 24 Internet explorer (3) - ie6 png 24 fix (3) - javascript png (3) - png transparent ie background (3) - PNG transparency IE6 (3) - IE6 Transparency Problems (3) - background png ie (2) - png internet explorer (2) - fix png transparency (2) - how to fix internet background (2) - transparency of png in IE (2) - transparent PNG in firefox and IE (2) - IE6 transparent background png fix (2) - png24 fix background-image (2) - ie6 png firefox (2) - png ie fix background (2) - transparencies with ie6 (2) - png 24 workaround (2) - how to fix png in ie6 (2) - background pngfix (2) - transparent png conditional (2) - background repeat png ie problem (2) - ie6 png transparency input fix (2) - jquery pngfix ie6 repeat (2) - ie png transparent (2) - hintergrundbild png beim IE 6.xx (2) - ie6 repeated background png fix (2) - javascript IE png opacity (2) - png24 fix (2) - explorer png transparency (2) - internet explorer 6 and transparency support (2) - png firefox explorer (2) - png24 invisible background ie6 (2) - transparence ie6 (2) - IE6 and .png (2) - png 24 im ie6 (2) - jquery png-24 transparent background fix (2) - png24 background ie fix (2) - myspace png ie6 (2) - ie6 transparenz link (2) -