CSS Id vs Class

2010-09-20


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