Center DIV's using CSS

Friday, August 1, 2008

Tables are dying a horrible death when it comes to web site design.
CSS
DIV based designs are already the preferred method of design for most web professionals.

I have had a couple of people asking me how to center DIV's using CSS.

Here is the CSS code to achieve this:

<style>
 #div1{
       width:200px;
       text-align:center;
       border:thin;
       background-color:#00CC00;
     }
 #div2{
       position:relative;
       margin:auto;
       width:100px;
       text-align:center;
       border:thin;
       background-color:#CC0000;
     }
</style>


Leave a Reply


Name*

Email

URL

Comment*

Enter numbers *
  Numbers

 *Required