htmlcssmargincenter-align

Align a div to center


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


Solution

  • 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.