max-width and height: auto for images in IE8

In IE8, if you have an image with the following markup and css:

<img src="image.png" width="400" height="300" />
img {
	width: 100%;
	max-width: 400px;
	height: auto;
}

the image height is going to grow past 300px in non-compatibility view!

In order to fix this issue add max-height: 300px; to the css.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>