Resize Image In Html Keep Aspect Ratio. So you have placed an image on your webpage and decided to resize it a little but a slight problem happened and the image goes out of proportions. If you are trying to maintain the same aspect ratio then wouldn t you resize by some percentage of the original size.

The full size image could be loaded on a click through from the thumbnail if that was what you wanted. If you do want to change the size on the page you need to make sure that. So you have placed an image on your webpage and decided to resize it a little but a slight problem happened and the image goes out of proportions.
The second example specifies a percentage of original image size both width and height instead of size in pixels.
With the height property set to auto your image s height changes proportionally with the width to ensure the aspect ratio is maintained. Since a percentage of image width and height is specified the browser can resize nearly any image and maintain its aspect ratio. The end result is an image that scales up or down perfectly. X px keep aspect ratio fill in the background with a solid color if the proportion of image changed.