How To Center A DIV Element

Published May 16th 2009 by
Filed under CSS

Centering a DIV Element doesn’t work the same as centering everything else. Using style="text-align:center" doesn’t work. There is still a way of centering it. You have to use the following css code:

style="width: 600px; margin-left: auto; margin-right: auto;"

Set the width to whatever you want it to be and it centers the DIV Element as you want it to.