title: Why doesn't "margin: auto" center an element vertically?
body: <p>As you can see in the demo below, <code>margin: auto;</code> centers the blue <code>div</code> horizontally, but not vertically. Why not?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.box {
    border: 1px solid red;
    width: 100px;
    height: 100px;
  }
  .center {
    background: blue;
    width: 50px;
    height: 50px;
    margin: auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="box"&gt;
    &lt;div class="center"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My question is not asking for workarounds.</p>