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


13 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

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 (155) - png24 ie6 (40) - transparent png ie6 (38) - png 24 ie6 (33) - fix png ie6 (31) - png ie6 (19) - png 24 ie (18) - png ie6 fix (16) - ie fix png (15) - transparent png in ie6 (14) - javascript PNG IE6 (13) - ie6 png background (12) - ie png fix background (12) - transparent png on ie6 (11) - transparent png firefox (10) - PNG IE background (10) - ie6 transparency problem (10) - transparency ie6 (10) - background png ie6 (10) - ie png background fix (9) - png-24 in ie6 (9) - ie6 png transparency (9) - ie png background (9) - png fix background (9) - PNG ie6 transparency (9) - transparency (8) - PNG-24 ie6 (8) - png background ie6 (8) - ie6 background png (7) - png (7) - png transparent ie6 (7) - png transparente Ie6 (7) - png ie6 background (7) - ie png transparency fix (7) - Transparent PNG background IE fix (6) - ie6 png-24 (6) - transparent png ie firefox (6) - png fix ie6 background (6) - fix png ie (6) - fix PNG background (5) - png background ie fix (5) - png transparency in IE (5) - png background explorer (5) - ie png fix (5) - IE6 transparency issue (5) - png transparency fix for IE6 (5) - fix png in ie6 (5) - transparency in IE (5) - transparency in IE6 (5) - png24 ie (5) - transparent png ie6 fix (5) - HACK explorer 6 BACKGROUND PNG (4) - ie opacity png background (4) - png for ie6 (4) - ie6 png transparent background (4) - IE png hack (4) - ie6 png 24 (4) - explorer png support (4) - png transparency in IE6 (4) - ie6 fix png (4) - png ie fix (4) - ie6 transparency support (4) - PNG transparency IE fix (4) - png 24 transparency (4) - png 24 ie 6 (4) - javascript png support in ie6 (4) - png background fix (4) - png background fix ie6 (4) - png transparency firefox (3) - IE6 transparency issues (3) - png IE transparency (3) - javascript png (3) - png 24 Internet explorer (3) - explorer png graphics (3) - fix PNG for IE (3) - ie background png fix (3) - transparence png ie (3) - png ie firefox (3) - fix background png (3) - PNG 24 and IE6 (3) - png background ie6 fix (3) - Прозрачность png в Internet Explorer (3) - прозрачность png internet explorer (3) - png-24 internet explorer (3) - ie6 png прозрачность (3) - PNG transparency IE6 (3) - png 24 ie6 fix (3) - png transparent ie background (3) - background png fix (3) - ie6 png hack (3) - how to png-24 in IE6 (3) - javascript IE6 png (3) - PNG-24 IE (3) - ie png 24 (3) - png 24 explorer (3) - fix ie png (3) - png-24 ie fix (3) - ie png transparency (3) - ie6 png transparency fix (3) - png24 background ie fix (2) - ie png transparent background repeat fix (2) - ie png-24 (2) - png 24 support IE6 (2) - how to fix png in ie6 (2) - png 24 ie fix (2) - png24 in ie6 (2) - transparent png conditional (2) - jquery pngfix ie6 repeat (2) - transparent PNG in firefox and IE (2) - myspace png ie6 (2) - javascript IE png opacity (2) - png24 fix (2) - transparencies with ie6 (2) - png 24 workaround (2) - ie png hell (2) - ie6 png firefox (2) - transparency of png in IE (2) - png24 invisible background ie6 (2) - png ie6 workaround (2) - fix .png in IE6 (2) - how to remove white backgrounds in explorer (2) - png24 explorer issue (2) - прозрачность png ie6 (2) - convert Pngs jquery (2) - script png ie6 js (2) - IE6 and .png (2) - best ie png background fix (2) - png24 fix for ie6 (2) - png explorer transparant (2) - png прозрачность в IE (2) - IE PNG-24 fix (2) - png24 fix background-image (2) - Transparent PNG in IE (2) - png firefox explorer (2) - png fix for background (2) - ie6 png transparency fix background (2) - png 24 on IE6 (2) - jquery png Fix distorted image (2) - background repeat png ie problem (2) - IE6 transparent background png fix (2) - background pngfix (2) - png transparency internet explorer 6 fix background-image (2) - png explorer background transparentes com repeat (2) - png background internet explorer (2) - in IE6 png images have a white background? how to fix (2) - ie png background fixed (2) - png transparent firefox (2) - javascript background png (2) - ie png transparent (2) -