I was shocked by this line "Don't use ID selectors in CSS". Is it true? I found many posts have written this.
- http://mattwilcox.net/archive/entry/id/1054/
- http://screwlewse.com/2010/07/dont-use-id-selectors-in-css/
- http://oli.jp/2011/ids/
I think we can use the ID for the selectors.
I still want to clear this up.
Id selectors have priority over other kinds of selectors. This can make it harder to add new rules using less specific selectors, leading to specificity wars: http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
I use id
selectors all the time. I know which elements are going to be unique and which are not, and an id
selector for unique elements (in my opinion) is best.
It is not advisable to use CSS selectors using IDs
because Then if another element in the page uses the same/similiar style,
you would have to write another class.
Even if you don't have more than one element right now , it might come later.
Hence it is always advisable to use class.