Forum Moderators: not2easy
Why should I avoid underscores in class names?
I've heard it affects SEO and I've heard some browsers have a problem with it. Is there any truth to either of these assertions?
Thanks.
References:
CSS2 Appendix D: The grammar of CSS2 [w3.org]
CSS1 Appendix B: CSS1 Grammar [w3.org]
Errata in REC-CSS2-19980512 [w3.org] (see "section 4.1.1 (and D.2)")
If I understand correctly, avoiding underscores in CSS is done primarily for backwards compatibility.
I tend to use the underscore as a way of combining classes into groups of similar items, such as:
table.Border_Left,
table.Border_Right,
and so on, with the appropriate properties for each. This gives me great flexibility with my tables - I display a lot of tabular data.
Am I correct that in the above examples I should replace the underscores with hyphens?
Unless I really need to get rid of the underscore, and given my audience it doesn't seem like it, I'm going to concentrate on bigger issues.
Thanks again for your help. It's much appreciated.