title: Why `padding:auto of parent div` does not same with `margin:auto of child div`?
body: <p>To center the child div in the parent div, I often use <code>margin: auto</code> in css.</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>.parent {
  width:500px;
  background: red;
  }
  
  .child {
  width:100px;
  height:100px;
  background: blue;
  margin:auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="parent"&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>However, considering the box model, it is margin in the child position but padding in the parent position.</p>
  
  <p><a href="https://i.stack.imgur.com/AyLov.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AyLov.png" alt="enter image description here"></a></p>
  
  <p>So, I try it.</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>.parent {
  width:500px;
  background: red;
  padding:auto;
  }
  
  .child {
  width:100px;
  height:100px;
  background: blue;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="parent"&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But this did not work like I thought. Do you know why?</p>