According to CSS principles when we want to implement reusability of styles we should use class
attribute and when we know that there is an unique element in whole DOM structure we should use id
attribute to that Element and then specify a style.
But in this era of Web Applications, DOM structure can be too complex and there is a possibility of duplicate id
. Best example would be #title
. Its kind of name which can appear anywhere in the document. Now the best part is if I use #title
or .title
while defining styles (assuming that they have been appeared more than once and have different parent) output which CSS generates is same. This jsfiddle will help you understand what I mean http://jsfiddle.net/dewbot/LGAQD/
I was under impression that just like JS Renderer, CSS Parser halts the iteration when it discovers first #title
but it does not happen it keeps on iteration till it reaches EOF just like class
. So this arises a question why should we use multiple class
and not id
?