Shivam Mitra Shivam Mitra - 9 months ago 64
CSS Question

Fitting an image to a div container in HTML

I would like an image to fit into a div container. It should fit even if the image is smaller than div or image is larger than div. I have tried some options like setting max-width and height to 100% but it doesn't work.

#content {
width: 351px;
height: 250px;
border: 1px solid black;
#content img {
max-width: 100%;
max-height: 100%;

<div id="content">
<img src="">

Here is my code link:

Answer Source
#content {
  border:1px solid black;
#content img {