title: How to resize image with CSS without altering image quality
body: <p>I have a Bootstrap carousel with the below code; how can I size this image to completely fill the carousel with losing image quality and also ensure the image height does not exceed the width or height of the carousel? <a href="https://i.stack.imgur.com/iHFvM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iHFvM.png" alt="image"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel"&gt;
    &lt;ol class="carousel-indicators"&gt;
      &lt;li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"&gt;&lt;/li&gt;
      &lt;li data-target="#carouselExampleIndicators" data-slide-to="1"&gt;&lt;/li&gt;
      &lt;li data-target="#carouselExampleIndicators" data-slide-to="2"&gt;&lt;/li&gt;
    &lt;/ol&gt;
    &lt;div class="carousel-inner"&gt;
      &lt;div class="carousel-item active" style="width:400px;"&gt;
        &lt;img class="d-block w-100" src="{{articles.image.url}}" alt="First slide" style=" width:100%;height:auto;"&gt;
        &lt;div class="carousel-caption d-none d-md-block"&gt;
          &lt;h5&gt;Latest&lt;/h5&gt;
          &lt;p&gt;{{articles.title}}&lt;/p&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="carousel-item"&gt;
        &lt;img class="d-block w-100" src=".../800x400?auto=yes&amp;bg=666&amp;fg=444&amp;text=Second slide" alt="Second slide"&gt;{% lorem 1 p %}
      &lt;/div&gt;
      &lt;div class="carousel-item"&gt;
        &lt;img class="d-block w-100" src=".../800x400?auto=yes&amp;bg=555&amp;fg=333&amp;text=Third slide" alt="Third slide"&gt;{% lorem 1 p %}
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"&gt;
      &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
      &lt;span class="sr-only"&gt;Previous&lt;/span&gt;
    &lt;/a&gt;
    &lt;a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"&gt;
      &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
      &lt;span class="sr-only"&gt;Next&lt;/span&gt;
    &lt;/a&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>