When you are building URLs that should be legible for users and search engines and you do it automatically from the content, what's the best way to represent blank spaces? Hyphens (this is what StackOverflow uses)? Underscores? Any other? Does any of those make a different for SEO?
I think that depends on your favorite. My favourites are underscores, but I don't see any (dis-)advantages if using hyphens or other valid URL characters instead. And everything looks better than %20 :)
Again, personal preference - personally I think hyphens work better than underscores, because underscores can clash with the underlining a tags add (by default), so http://someurl.com/this_is_a_address looks like there are no underscores there. (as this is stack overflow, roll over the link). http://someurl.com/this-is-a-address looks fine.
Both are valid URL characters and both have their pros and cons.
Pro dash
Google recommends dashes, and here is what Matt Cutts from Google has to say about Dashes vs. underscores.
If you have a url like word1-word2, that page can be returned for the searches word1, word2, and even “word1 word2″. That’s why I would always choose dashes instead of underscores.
- Dashes seem to be what major blogs do: The Huffington Post, TechCrunch, Engadget, ...
Dashes seem to be what major CMS do.
Not sure about that one anymore, can anyone comment?- As mentioned by Kazar, underscores can clash with the underlining of links.
- I find underscores awkward to type.
- Rene Saarsoo pointed out that dashes take less space than underscores in proportional fonts.
- Ionut G. Stan mentioned that underscores are not allowed in hostnames. If you strive for consistency you should opt for dashes.
Pro underscore
- Dashes are not allowed in ISO9660 file systems. This can be a problem if your content is also shipped on DVD or CD (e.g help files or eLearning content).
- In some languages (e.g. German) dashes can be word characters and are not generally considered word separators.
I'd say dashes. I used to use underscored for pretty much every such purpose (representing spaces) but nowadays, with all the visual thingies blinking all round, you often find underlining that makes them normally invisible.
You know, if you buy a domain name, you're allowed to use hyphens inside that name, but no underscores. This is an additional reason for which I believe hyphens are better than underscores.
Another advantage of dashes is that in proportional font they take less space that underscores. Compare:
- http://stackoverflow.com/../whats-the-best-character-to-represent-blank-spaces-in-a-url
- http://stackoverflow.com/../whats_the_best_character_to_represent_blank_spaces_in_a_url
It's not a lot, but every little helps :)