title: How to set margin: auto to an unordered list? <ul>
body: <p>I need to center a <code>&lt;ul&gt;</code> element using <code>margin: 0 auto;</code></p>
  
  <p>If I set the width for the ul element (<code>width:300px</code>) then its works fine. But I can't do this since it is a dynamic list, then the width changes all the time.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div&gt;
  &lt;ul&gt;
  &lt;li&gt;hello&lt;/li&gt;
  &lt;li&gt;bye&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>CSS:</strong></p>
  
  <p><code>ul{margin:0 auto;}</code> But it isn't working.</p>
  
  <p><code>ul{margin:0 auto;width:300px;}</code> Works, but I can't set the width in this way.</p>