opensourcewebsolution
A complete Open Source solutions provider...
Are you looking for Open Source template customization Company in India? Joomla, Oscommerce,PHPbb, Typo3, Drupal, PHPNuke, POSTNuke, Mambo, Zen Cart template customization work? You are at right place.
| The Difference Between Class and ID in CSS |
|
| Frequently while spying on others' CSS files (it's the best way to learn – really!) I'll notice a distinct difference between the frequency at which they use ID selectors versus Class selectors. I've always leaned toward using class over id in my CSS, but never for a good reason. Today I decided to look up the difference between class and id and learned quite a bit in the process. Both Evrsoft and css-discuss provide very useful information on the subject, and they both distinguish the difference between class and id as follows: The key thing to know is that IDs identify a specific element and therefore must be unique on the page – you can only use a specific ID once per document. Many browsers do not enforce this rule but it is a basic rule of HTML/XHTML and should be observed. Classes mark elements as members of a group and can be used multiple times, so if you want to define a style which will be applied to multiple elements you should use a class instead. As it turns out, I've probably been better off all along by sticking to my class over id mentality. However, it's good to know that id has a specific purpose. Hopefully now I'll be able to use both selectors correctly when they are appropriate. |










