CSS Center

1: Center Fixed-Width Layouts:

DIV#silverlightControlHost_centered
{
width:800px;
height:500px;
margin-left: auto;
margin-right: auto;
}

But some old browsers do NOT support above code

2: Center the body

body
{
    text-align: center;
}

div#container
{
    margin-left: auto;
    margin-right: auto;
    width: 50em;
   text-align: left;  /* IF you want to reset text align */

}

CSS Id vs Class

ID is unique
    * Each element has only one ID
    * Each page has only one element with that ID
    * Defined with “#”

Example

#myid
{
text-align:center;
color:red;
}

Classes is NOT unique
    * The same class can be used on multiple elements.
    * Multiple classes can be used on the same element.
    * Defined with “.”

Example

.center {text-align:center;}

OR

div.center {text-align:center;}