Center div with CSS

02 March 2009 | Tips & Tricks | Tags: ,

Simple example how to center a div with css.

Open your CSS file and write:

body { text-align: center; }

.centerdiv {
margin: 0 auto;
width: 200px;
text-align: left;
}

Now open your index or what ever you want to put your div and create it:

<div class="centerdiv">text</div>


Leave a Reply