Do you avoid having width and height properties in image tags?

Last updated by Tom Bui [SSW] 7 months ago.See history

Specifying the width and height properties for images on your web pages can sometimes turn out to be more trouble than it's worth, particularly if the image is updated with different dimensions. Adding fixed widths to your images also disrupt your content on any responsive websites.

In other words, you should not have the image dimensions specified in HTML unless you have a very specific reason to do so. Use CSS if you need to specify images dimensions.

<img src="MyPic.gif" width="93" height="25">

Figure: Bad example - Including the width and height properties for content images

<img src="MyPic.gif">

Figure: Good example - Exclude width and height properties for content images

We open source. Powered by GitHub