CSS Id vs Class

Published on Monday, September 20, 2010

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;}