Center a div inside of a div


/ Published in: CSS
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. #inner {
  2. width: 50%; /* This is a example number */
  3. margin: auto;
  4. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.