Design Oahu

Web design blog from the middle of the pacific.

IE PNG Transparency Part I

IE PNG
I have wanted to work with PNG-24 images on the web for a long time now, but have stayed away due to the fact that Internet Explorer does not recognize the transparency natively. Thanks to Erik Arvidsson’s fix, I no longer have to worry. I was a little bit confused by Erik’s write up, and I am pretty Otaku (Japanese for Geek), so this is a quick and dirty tutorial on getting it running on your website. The only thing you need to do is include this small bit of text in your CSS file:

img{

behavior: url(”pngbehavior.htc”);

}

The pngbehavior.htc file does all the work. The only other thing you need is a blank image file. You can create a 1 pixel by 1 pixel transparent GIF image for this. Make sure the pngbehavior.htc file has the correct location of the blank.gif image in case you placed it in a different directory. That is all there is to it! One thing you must do is specify the width and height of the image, though I am sure you are doing that for accessibility sake already:P Take a look at my PNG Transparency Demo.

Download the Demo:

IE PNG Demo

Update: Check out IE PNG Transparency Part II to use transparent PNGs inside you CSS. This is the technique I used when creating the Beer WordPress Theme.

If you liked what you read you may be interested in subscribing to our RSS feed or email alerts. You may also want to read up about what RSS feeds are all about.

66 Comments

  1. Comment by Ryan on January 17, 2007

    thats actually really interesting. I dont personally use png-24 files all that often, but I might now. I’ve seen some sites that use them very creatively but wondered how they got around the IE frustrations….I suppose this is how, thanks for the tip!

  2. Comment by Jeremy on January 18, 2007

    I’m glad that this helped you Ryan. Please come back and post a link if you end up using this in a project, I would be interested to see how you used it.

  3. Comment by simonjs on January 26, 2007

    I’ve been using a javascript fix which does a similar thing but the script increases the page load time quite significantly - this looks much quicker! great!

  4. Comment by vasilis on January 29, 2007

    That’s nice! What if you want to use PNG-24 as background image? Will be nice if there is a similar workaround also for that!

  5. Comment by Nite on January 29, 2007

    I use png all the time, all other browsers (inc. IE for Mac, from ‘94 on) understand png transparency. I hate IE anyway, so I don’t give a flying f*ck if that piece of broken code doesn’t display something right, it doesn’t even understand css right. But this is just so simple a fix I might even incorporate this as I don’t have to work my ass of to make some stupid excuse of a browser understand standards. Sorry for the ramble :D

  6. Comment by Jeremy on January 30, 2007

    @vasilis
    I recently discovered that too. I can’t figure out repeating tile patterned PNGs, but got the background images working as well as a repeating solid color background. Take a look at PartII of this article. I added a link at the end of the post.

    @simonjs and Nite
    I’m glad it helped you out.

  7. Comment by Jani Saksa on February 23, 2007

    Fine guide - I’d like to not just care about IE and once for a period of time I had forgotten to even think about it (I use linux). Later I managed to install IE under linux+wine to test the sites that I have made and make because while they worked perfectly on other browsers I noticed that many of them looked more or less (many times more) flawed (were not, looked - IE is what is flawed) and almost everytime I design a website a big part of the time goes to after-editing the page to work under IE correctly! That’s why I often make my webpages and even CSS-files with PHP so that I can check if the browser requesting the page is IE and offer ie-specific version of them - Before this I used to disable some images and replace some with .gif or .jpg version’s of the image on IE-version. At least now I don’t need to worry about that anymore (and as for versions older than 5.5 - hardly nobody uses them - though my friend has 5.0x (uses it only for windows update though) - so I don’t care about them showing wrong on that old versions - they mess the pages often in many other ways too, so that making specific versions for them would be way too much work for way too few users…

    Anyway, I already thanked you about this guide on email, but decided to write here too for others to see how I appreciate your work :)

    Btw, on my css-php scripts I send the “img { behavior: …” thing only to IE, because I like to have my CSS (and HTML) w3c compliant and behavior: is not valid css property, so I only send non-valid css-code to IE…

    You can see the source of my latest one here:
    http://millajaakkola.kapsi.fi/?osa=source&filu=css
    It’s a finnish site, but it’s the source-code section and the miffy.css.php loads with that link… you can check the other .php files on that page too, it shows the source code neatly - index.php has some checks too for IE (and links, which does not support css).

  8. Comment by Atters on July 31, 2007

    This fix looks just fantastic! But I’ve been trying to use it for the last week and just can’t work it out. I wonder if anyone would be so kind to zip up the demo page with all the files and folders needed to do the fix? Basically a working downloadable example. The closest I got this to working was when all my PNGs just disappeared! Sorry for being a nong but I am really struggling on this one. Cheers, Atters.

  9. Comment by Jeremy on August 1, 2007

    Wassup Atters,

    Please make sure that you specified the width and height of your image otherwise it will not work. If it doesn’t work let me know and I will package a zip file for you with an example.

    Jeremy

  10. Comment by Atters on August 1, 2007

    Yeah I thought of that but still no luck. I feel like an idiot because I’m usually all over this sort of thing. I really appreciate your help Jeremy.

    Cheers mate,
    Atters.

  11. Comment by Jeremy on August 1, 2007

    Hey Atters,
    The only other thing that I can think of is that in your pngbehavior.htc file you are not specifying the correct location of the blank.gif file. Anyways, I have created a zip file of the demo you can get it here: http://designoahu.com/iepng/iepng.zip
    Good luck, and please post a link to the site you end up using it on if you get it working. Also, let me know if you still have troubles.

    Jeremy

  12. Comment by Atters on August 2, 2007

    Your a legend Jeremy, good onya. Will do.
    Atters.

  13. Comment by Jani Saksa on September 13, 2007

    I havent tested on real windows (my downgraded computer has too little memory to run windows at any kind of usable speed), but with IE’s (5.5 & 6) I get the problem that the image does not show correctly, it just dissapears after showing for a part of second on the screen (without transparency) - Is this problem with wine or is there something missing from my IE installations under Linux+Wine? It seems, judging from the comments (and I think I checked the site at school with IE too and it worked) it does work at least for most people…

    Any idea?

  14. Comment by çiçekçi on March 14, 2008

    thanks

  15. Comment by volkan on March 20, 2008

    Thanks.

  16. Comment by cicek on June 11, 2008

    tanku you

  17. Comment by Roger on July 23, 2008

    Hi there…
    I kept almost the whole day trying to find a solution for the png transparency thing around the web. Most of them didn’t work at all.
    But yours is pretty close to work well. But I’m still having one problem:
    - the png transparency is working, but the links and form entries are not.

    I will try to find a sollution around the web, because I’m pretty sure I’ve readen something about this today. But if you could send me an e-mail or reply here giving the instructions for fixing this, it would be nice… 8^)

    Anyway, I’m already happy to see the transparency… hehe…

    I’ll bookmark this page, so I can remember your site to come back.
    See you! 8^)

  18. Comment by Jeremy on July 24, 2008

    @Roger

    So is your transparent images the background for the form and links? Can you post the URL, and I will take a look.

  19. Comment by Umka on July 30, 2008

    Thanks a LOT!!! I needed this right now:)

  20. Comment by Pwhndvve on August 9, 2008

    Rimsky went look closer buy cytotec then announced held.

  21. Comment by Nick on November 19, 2008

    @Jani Saksa: I am having the same issue, however I am using a program called IETester. It has the engine from 5.5, 6 and 7. 5.5 and 6 both show it for a second then it completely dissapears.

  22. Comment by forex on December 24, 2008

    thank you

  23. Comment by kabin on December 24, 2008

    thanks

  24. Comment by otomatik kapı on December 25, 2008

    thank you so macht

  25. Comment by vinç on December 25, 2008

    Your a legend Jeremy, good onya

  26. Comment by burun estetiği on December 25, 2008

    thank you

  27. Comment by vinç on December 25, 2008

    thanks

  28. Comment by tabela on December 25, 2008

    thank you

  29. Comment by konteyner on December 26, 2008

    thank you for article

  30. Comment by işitme cihazı on December 26, 2008

    thanks

  31. Comment by sürücü kursu on December 26, 2008

    Thanks a LOT

  32. Comment by özel güvenlik on December 27, 2008

    thank you

  33. Comment by kbb on December 27, 2008

    thank you very much

  34. Comment by kablo on December 27, 2008

    thanks

  35. Comment by buhar kazanı on December 30, 2008

    thank you for article

  36. Comment by ankara rehberi on December 30, 2008

    thank you

  37. Comment by çelik kapı on December 30, 2008

    thank you very much

  38. Comment by karot beton delme beton kesme on January 4, 2009

    thanks

  39. Comment by reklam ajans web tasarımı matbaa on January 4, 2009

    hello

  40. Comment by parca kontor on February 1, 2009

    parça kontör parça kontör parça kontör parça kontör parça kontör parça kontör parça kontör parçakontörparça kontör parça kontör parça kontör parça kontör parça kontor parça kontor parça kontorparça kontorparça kontor parça kontor parça kontor parça kontor parça kontor parça kontor parça kontor parça kontorseks seks seks seks seks seks seks seks seks seksseks seks sex sex sex sex sex sex
    mirc mirc mirc mirc mirc mirc haber haber haber haberhaber haber haber haber haber haber haber haber futbol futbolfutbol futbol futbol futbol futbol futbol futbol futbol futbol futbolresim resim resim resim resim resim resim resim resim resimresim resim web tasarım web tasarım web tasarım web tasarım web tasarım web tasarım web tasarımweb tasarım web tasarım web tasarım web tasarım web tasarım

  41. Comment by REKLAM ajans on February 1, 2009

    resim resim resim resim resimresim resim web tasarım web tasarım web tasarım web tasarım web tasarım web tasarım web tasarımweb tasarım web tasarım web tasarım web tasarım web tasarım

  42. Comment by hosting ve domain on February 1, 2009

    resim resim resim resim resimresim resim web tasarım web tasarım web tasarım web tasarım web tasarım web tasarım web tasarımweb tasarım web tasarım web tasarım web tasarım web tasarım

  43. Comment by haber haberci haberler on February 1, 2009

    haber haberler

  44. Comment by bilgisayar,bilgisayar parcaları on February 1, 2009

    resim resim resim resim resimresim resim web tasarım web tasarım web tasarım web tasarım web tasarım web tasarım web tasarımweb tasarım web tasarım web tasarım web tasarım web tasarım

  45. Comment by forex on April 3, 2009

    nice article.thanks

  46. Comment by çiçekçi on April 15, 2009

    thankyou
    istanbul çiçekçi

  47. Comment by cicek on June 15, 2009

    leven te online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  48. Comment by cicek on June 15, 2009

    beşitaşa online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  49. Comment by cicek on June 15, 2009

    şişliye
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  50. Comment by cicek on June 15, 2009

    mertere
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  51. Comment by cicek on June 15, 2009

    taksime online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  52. Comment by cicek on June 15, 2009

    maslak çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  53. Comment by cicek on June 15, 2009

    akmerkez çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  54. Comment by cicek on June 15, 2009

    kavacık çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  55. Comment by cicek on June 15, 2009

    beykoz çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  56. Comment by cicek on June 15, 2009

    ümraniye çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  57. Comment by cicek on June 15, 2009

    dudulu çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  58. Comment by cicek on June 15, 2009

    çekmeköy çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  59. Comment by cicek on June 15, 2009

    ünalan çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  60. Comment by cicek on June 15, 2009

    kadıköy çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  61. Comment by cicek on June 15, 2009

    avcılar çiçek
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  62. Comment by cicek on June 15, 2009

    bakırköy çiçek online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  63. Comment by cicek on June 15, 2009

    şirin evler
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  64. Comment by cicek on June 15, 2009

    ataşehir
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  65. Comment by cicek on June 15, 2009

    kızıltoprak
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

  66. Comment by cicek on June 15, 2009

    fenerbahce
    online ciceksiparisi gönderin 0216 325 39 36 0212 351 37 85

Leave a Comment

Trackbacks

  1. Hawaii Website Design » IE PNG Transparency Part II
  2. Daily Links | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster?