The golden rules goes as this: use id
for chrome elements, use class
for content elements. So method 2 is the better.
You can read this article on css-discuss for inspiration: http://css-discuss.incutio.com/wiki/Classes_Vs_Ids
There is nothing that stops you from using id
attributes on unique content elements, and in some cases it can be a nice way to speed up javascript DOM traversals. For styling purposes, however, it is considered by many as bad practice.
The main points to consider are these:
- classes can be used for multiple inheritance, id's needs to be unique
- selector specificity can become a nightmare if you need to use inheritance paired with id styling
Whenever I use id
attributes on non-chrome elements it is purely for fast javascript access, and never for styling.