On new projects I use separate words with hyphens. When working on an existing project I try to follow any obvious patterns. I much prefer separate words, all lower case w/ hyphens. Server and client-side programming I tend to go with camel case except in templates where the convention seems to be underscore or form field name attribute.
Although, I think I would be slightly irritated if I had to deal with names like: firstname where all words were just squashed together. That to me just seems highly unreadable in comparison to the alternatives that at least have some type of visual break between words. Besides that though I don't think there is a best way to name classes and ids. Pretty much what your are comfortable with until you inherit another persons work.