PNGs are a handy tool for web developers to use when creating websites. There are a lot of misconceptions about them, and I hope to clear the air in this article. We will define what PNGs are, how they differ from JPG and GIF, what the misconceptions are, and finally a little bit on how to get them to behave in IE6.
PNG is an image format comparable to JPG and GIF. It stands for Portable Network Graphics. PNG was originally created to eliminate GIFs and provide better compression at a higher quality.
Each image format is still around, and thus means they each have their own strengths and weaknesses. JPG is great for photographic images. Images with gradients and lots of colors are great for JPG. GIF on the other hand is great for logos, and images that have large areas of one color. This normally means there is not a wide range of colors and GIF
The major differences between GIF and PNG are the following:
The following is a skimmed down list of some of the Misconceptions out there about PNG. Don’t feel bad if you have fallen into these misconceptions as I have as well.
I have taken these from a great article on CSS-Tricks titled, Misconceptions about PNG, so please check it out!
This is probably the biggest reason that PNG has not taken off more than it has. Its support is limited at times and Internet Explorer chokes on them. Actually it really only chokes when transparency is involved. To our relief, there are many easy fixes out there for us to use.
I suggest you read, 5 Easy Ways to Tackle IE6’s Transparency Issues from NETTUTS for more of an in depth description of each of the following.
<!--[if lt IE 7]>
<script type="text/javascript" src="unitpngfix.js"></script>
< ![endif]-->
<!--[if IE 6]>
<script type="text/javascript" src="DD_belatedPNG.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix('.png_bg');
</script>
< ![endif]-->
<style type="text/css">
img, div, a, input { behavior: url(/css/resources/iepngfix.htc) }
</style>
That about does it for PNGs. You are all PNGed out I am sure…
Why not explain the differences between the three fixes? I’ve had hard times dealing with PNGs in IE6 on my websites until I dropped the support for IE6. That is because I could not find a single solution that would work nice whenever I needed it to.
January 26th, 2009 at 10:09 am
Great article, short and to the point. I’ll be saving it into my articles folder in FireFox. Thanks!
Anthony
January 26th, 2009 at 10:35 am
Animated PNGs: http://en.wikipedia.org/wiki/APNG
January 26th, 2009 at 10:37 am
Wow! Thanks Jeff, I didn’t even know that option was out there. Probably isn’t well supportted though.
Never heard of APNG (Animated PNG)…
Stop using those stupid script already, use PNG8 for backward compatible alpha transparency!
http://www.sitepoint.com/blogs/2007/09/18/png8-the-clear-winner/
Wow Henry! Thanks for pointing that out… this must be one of your habored secrets!
I use Photoshop and didn’t realize PNG8’s could do transparency!
January 27th, 2009 at 11:20 pm
[...] by a comment on my previous blog post titled, PNGs, PNGs, and more PNGs I have decided to record a 15 minute screencast to show you how to use PNG-8 for [...]
It is also a common misconception, that some browsers support GIFs, but not PNGs. This might have been the case in the 1990s, but doesn’t hold true anymore. I even sort of remember one of my browsers not to display GIFs once (libungif excluded on Debian or something?).
Here’s another fix, that works perfect (and you don’t even see it change the pngs). Include the following in your <head>
and rename all your png files to end with “-trans”. ( Ex: my.png -> my-trans.png)
Cheers!
Twitter
Follow me on Twitter to keep up to date!
RSS Feed
Keep up with all of our updates by subscribing to our RSS feed!
FaceBook
Join our group on Facebook and become a fan of us!