How do I fit an image (img) inside a div and keep the aspect ratio? July 24, 2022 by Tarik Use max-height:100%; max-width:100%; for the image inside the div.