Or is it just mainly a personal preference?
As a programmer I always use underscore, but have seen it as -
a开发者_运维百科nd so I will have to conform to it working in that project.
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.
To-may-toe, To_mah_toe.
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.
I don't think hyphens are any better for SEO. That's why people try to avoid domain names with hyphen. We should not be confused for hyphen in search box or address bar of the browser. Hyphen in address bar is totally different world from programming.
I had few problems with hyphen not sure why but image names, database and table names and files and directories with hyphen give problem in some cases (specially in css). So, I do not recommend hyphen and always follow underscore.
check this https://stackoverflow.com/a/10768014/1419238
If anyone know the reason for this, please share your knowledge
精彩评论