title: Why an image with 100% width in inline-block behaving as responsive image
body: <p>I am absolutely new to HTML &amp; CSS and trying to learn it, hence this question. My target was to create a responsive image which doesn't exceed the original size of the image. Found some info on <a href="https://stackoverflow.com/questions/26747848/making-an-image-width100-inside-a-inline-block-element">this question</a> and I was able to do it by putting the image in an inline-block which is in a div (see the code snippet), but it doesn't answer a fundamental question. How is the responsiveness working.</p>
  
  <p>For the case when the viewport is larger than the image, my HTML code makes sense i.e. the width of the image is 100% which means take the size of the parent container. In this case the parent container is inline-block whose size is actually the size of the content it's enclosing, so 100% means the image will be displayed with it's original size.</p>
  
  <p>But when I resize the browser window to a smaller size, the image resizes with it. Here I am not able to understand the mechanism of action. As per my info (which is limited as of now) the inline-block always takes the size of contents it's enclosing, then how come it's resizing when the outside container is changing it's size.</p>
  
  <p><strong>Is it something that inline-block will take the size of the content TILL it's fitting in the parent container BUT as soon as the parent container is not sufficient to fill the inline-element, the inline-element will resize to the parent container and NOT the content it has in itself?</strong></p>
  
  <p>P.S. - My first question on Stack Overflow.</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-css lang-css prettyprint-override"><code>.container {
    border: 2px solid black;
    padding: 5px;
    text-align: center;
  }
  
  .responsive-image {
    width: 100%;
    max-width: 1920px;
  }
  
  .inline-block {
    display: inline-block;
    border: 2px solid purple;
    padding: 3px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;div class="inline-block"&gt;
        &lt;img class="responsive-image" src="https://drive.google.com/uc?authuser=0&amp;id=0B3Fs1er7k9QAQUU1bzhqYWMxeUU"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>