Tuesday, November 29, 2011

Difference between CSS Class and ID selector


The first difference is
An ID selector can be called only once in a document.
A class selector can be called multiple times in a document.

The second difference is
ID can be called by Javascript's getElementByID function.

Note1: There is no hard rule on when to use ID and when to use Class. Use class as much as possible for maximum flexibility, with the only exception being when you want to use Javascript's getElementByID function, in which case you need use ID.

Note2: Class and ID names are both case sensitive. For example, .divclass and .DivClass are two different classes.

Stumble
Delicious
Technorati
Twitter

0 Comments:

Post a Comment