Posted By

alozuldo on 10/25/10


Tagged

div width auto margin center inside


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

alozuldo
ratz2


Center a div inside of a div


 / Published in: CSS
 

URL: http://stackoverflow.com/questions/114543/how-to-center-div-in-div

Of course, you don't have to set the width to 50%. Any width less than the containing div will work. The margin: auto is what does the actual centering.

  1. #inner {
  2. width: 50%; /* This is a example number */
  3. margin: auto;
  4. }

Report this snippet  

You need to login to post a comment.