title: How to fit a image in div wather image size is max then div or min then div
body: <p>How do I fit an image in div? Image size can be max then div or min then div.</p>
  
  <p>html code </p>
  
  <pre><code>&lt;div class="main"&gt;
    &lt;img scr="image.jpg"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS code</p>
  
  <pre><code>.main{
    height:200px;
    width:200px;
  }
  
  img{
    // answer code
  }
  </code></pre>
  
  <p>How do I set image css with following:</p>
  
  <ol>
  <li>image height 100 and width 100</li>
  <li>image height 300 and width 300</li>
  </ol>