I needed to center a div with dynamic content, so I couldn’t set a fixed width.
Since margin: 0 auto; really won’t do anything if the element doesn’t have a fixed width you can solve it like this:
HTML
<div id="container"> <div class="centered">My dynamic content, that will be centerd</div> </div>
CSS
.centered { margin: 0 auto; display: table; }