A lot of web designers new to the field aren't aware of the differences between ID's and classes.
ID's and What They're For
Browsers use fragment identifiers as well. If you want to place a link at the top of your page that will scroll the browser down to the content when clicked, simply add id="content" to the content element or header above your content and use the following anchor:
Classes, like ID's, can also be used in JS scripts, but unlike ID's, they can be used multiple times in the same HTML document. This separation of content from presentation is what makes sites powered by CSS more robust, but some designers don't know the full extent to which they can use classes. Classes can not only be used more than once, but more than one can be used on an element:
The second piece of code is perfectly valid HTML, it demonstrates a div using two separate classes. This technique can reduce your CSS style sheet considerably when used effectively. It's also worth noting that you can use both ID's and classes on the same HTML element.
When to Use One or the Other
It's up to you, but so long as you implement classes and ID's properly, it is more or less a matter of personal choice when to utilize one or the other.