Today, while trying to fix broken rendering of aero-bg.com on Firefox, I delved deeper in CSS of site. Interesting though the css, almost randomly used in some cases ids and in other classes. I almost forgot, what the difference between those selectors are, so I refreshed myself, reading this incredible peace of info. To make things short, this is what are important differences:
1. Repeated use within a document
2. Combining class selectors
You can use multiple classes to style an HTML element but you can only use one ID when styling an HTML element. This means that class selectors have a wider range of applications.
3. IDs have higher specificity than classes
There may be times when a declaration conflicts with another declaration. These conflicts are resolved using the Cascade rules. In simple terms, if a class selector and ID selector were to be in conflict, the ID selector would be chosen.
Also following article has it's controversal way to detach scripts for handling DOM events, from presentation.
1. Repeated use within a document
- Classes can be used as many times as needed within a document.
- IDs can only be applied once within a document.
2. Combining class selectors
You can use multiple classes to style an HTML element but you can only use one ID when styling an HTML element. This means that class selectors have a wider range of applications.
3. IDs have higher specificity than classes
There may be times when a declaration conflicts with another declaration. These conflicts are resolved using the Cascade rules. In simple terms, if a class selector and ID selector were to be in conflict, the ID selector would be chosen.
Also following article has it's controversal way to detach scripts for handling DOM events, from presentation.