I've been wondering about this lately...
If I have a div that's the container for my layout and I want to center it, what's the best way? Generally, the div that I use to contain my layout is floated left, so the auto margins don't work.
I end up with code that looks like this...
Code:
#container {
width: 750px;
margin-left: auto;
margin-right: auto;
}
#content {
float: left;
width: 750px;
}
HTML Code:
<div id="container">
<div id="content">
</div>
</div>
Now this may not seem like a big deal, but when you need to add padding or a border without extending the width of the div in certain browsers, it can end up quite messy, with multiple more divs starting out your page.
Is there a better way to do this? Or am I stuck with this mess?