Images Display in Firefox and Safari, but not in Internet Explorer

I ran into a little "gotcha" today where an image was displaying properly in Firefox and Safari, but not in Internet Explorer. The weird thing is that it wasn't showing up as a broken link (no missing image icon with the infamous red 'X'). Instead, it wasn't showing up at all:

<img src="/path/to/image/filename.jpg" alt="Sample Image" width="" height="" />

As it turns out, if you have the width and height attributes set to an empty string, IE seems to interpret the width and height as zero, which makes the image not appear. All other browsers, of course, seem to discard the empty attributes.

The solution? Simply remove the empty attributes or plug in the appropriate values.

Author avatar

About the author

Creator of Surreal CMS and other web things. Follow me for tweets about JavaScript, CSS, and web programming.