title: Align element to right with margin-left: auto
body: <p>I would like to align an element to the right. I know that I should use float right to align an element to right, but I have a complex project and I need to understand why margin: 0 0 0 auto; align an element to the right in a case and why it does not work in other case.</p>
  
  <p>When the container is a flex container, the margin: 0 0 0 auto; aligns the element to the right as you can see in this example:</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>div {
    display: flex;
    width: 400px;
    background: #eee;
  }
  
  span {
    margin: 0 0 0 auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
    &lt;span&gt;test&lt;/span&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But when the container is not a flex container, the item stays on the left:</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>div {
    width: 400px;
    background: #eee;
  }
  
  span {
    margin: 0 0 0 auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
    &lt;span&gt;test&lt;/span&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>Is it possible to align an item with margin to the right without using flex on the container?</li>
  <li>Does the Flex example works as how it should work or is it a bug in flexbox?</li>
  </ul>