css - Image - Resize an image dynamically

img {
  max-width: 100%;
  height: auto;
  width: auto\9; /* ie8 */
}

NOTE: max-width:100% and height:auto works in IE7, but not in IE8 (yes, another weird IE bug). To fix this, you need to add width:auto\9 for IE8.

and if you want to enforce a fixed max width of the image, just place it inside a container, for example:

<div style="max-width:500px;">
  <img src="..." />
</div>