views:

54

answers:

3

Or is it just mainly a personal preference?

As a programmer I always use underscore, but have seen it as - and so I will have to conform to it working in that project.

+2  A: 

To-may-toe, To_mah_toe.

Jaymz
+2  A: 

I understand hyphens to be more SEO friendly for URLs. This may cary over in some odd case to CSS class and id names, although I can't think of any particular instance off the top of my head.

Both are valid, I think it just breaks down to personal preference.

jordanstephens
Aside: this is (allegedly) because search engines treat "pickle_sandwich" as one keyword, but would split "pickle-sandwich" into two. The hyphen thus allows searching for either order of the words "sandwich pickle" or "pickle sandwich" whereas the underscore restricts the word order.
Andrew Vit
you mean some search engines may use element's ID and class to classify the content? that could be huh, if they see main-div vs main_div or mainDiv.
動靜能量
That's what I mean, *maybe*, **some** search engines would also consider this. I don't know of any concrete evidence, just speculation. bottom line is personal preference.
jordanstephens
A: 

Ok, I came to some situation where using hyphen is better too -- when we grep for our code, if we grep for "image-box", then the programming code such as add_to_image_box won't cluster up the results. As since it is more search engine friendly, I think it is a pretty good practice to use the form image-box instead.

動靜能量