My_css_class VS my-css-class
One of the reasons for the underscore transition is that it is consistent with naming variables and types in other languages (C *, Java, etc.). I think it's a little better to go with something familiar to make it more natural to read the source (and faster).
Otherwise, other suggestions made good sense. Perhaps you can quickly chat with your team and go with what works best for everyone.
a source to share
Either everything is fine - I would choose the one that you (and your colleagues) find the most readable. You won't find any gains or losses with either, it's just an aesthetic choice.
But whatever you do - once you choose a style - stick to it . Consistency is key to making these decisions.
a source to share
I would go with a hyphen. Because there are browsers that don't understand underscores in class names because they are not yet allowed in CSS 1.
a source to share
I agree with everyone here - none is better, but pick one and stick with it .
I personally use hyphens for the same reason as Andrew, they are easier to type. However, I also use underscores to target the jQuery class.
This way I can have ".modal-popup" for styles.
And then I can have a "._rollover" to target and apply functionality to specific elements without worrying about applying unwanted styles. "._rollover" will never have any style information to it.
This is kind of a hack, but a good way to get around the HTML selectable attribute limit.
a source to share
If you are using hyphens, you can use an |=
attribute selector to select a group of classes based on the first part of the class name:
/* Select open folders */
.folder-open { }
/* Select closed folders */
.folder-closed { }
/* Select both kinds */
*[class|="folder"] { }
The browser has different support for this type of selector.
a source to share