Horizontally Centering a div with CSS

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

Centering a div with css is easy, but there are some compatibility quirks...

Copy this code and paste it in your HTML
  1. #wrapper {
  2. text-align: center; /* IE misinterprets this so it centers the child div */
  3. min-width: 600px;/* To keep the look on resize for mozilla */
  4. }
  6. #centered {
  7. margin:0 auto; /* sets left and right margin to auto. Works for mozilla, not for IE */
  8. width:600px; /* or whatever size for the div */
  9. text-align: left; /* to override wrapper IE misinterpretation */
  10. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.