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


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.