Align a div to center

ACP picture ACP · Nov 16, 2009 · Viewed 351.7k times · Source

I want to float a div to center. Is it possible? text-align: center is not working in IE.

Answer

cletus picture cletus · Nov 16, 2009

There is no float to center per se. If you want to center a block element inside another do this:

<div id="outer">
  <div id="inner">Stuff to center</div>
</div>

with:

#outer { width: 600px; }
#inner { width: 250px; margin: 0 auto; }

Now that won't make the text wrap around it (like it would with a float left or right) but like I said: there is no float center.