CSS force image resize and keep aspect ratio

img {
  display: block;
  max-width:230px;
  max-height:95px;
  width: auto;
  height: auto;
}
<p>This image is originally 400x400 pixels, but should get resized by the CSS:</p>
<img width="400" height="400" src="http://i.stack.imgur.com/aEEkn.png">

Expand snippet

This will make image shrink if it’s too big for specified area (as downside, it will not enlarge image).

Leave a Comment