How to Horizontally Center DIV in DIV with CSS

Jun 26, 2012, by admin

CSSOuter DIV

<div id=”outer” style=”width:100%”>

<div id=”inner”>Foo foo</div>

</div>

 You can apply this CSS to the inner div:

 

#inner {

width: 50%;

margin: 0px auto;

}

you don’t have to set the width to 50%. Any width less than the containing div will work. The margin: 0px auto is what does the actual centering.