Forum Moderators: open
let say, which one should be used?
1. <div id="mainBody"> ... </div>
2. <div id="main_body"> ... </div>
3. <div id="main-body"> ... </div>
I say (3), why?
It is obvious, a spider like Google can split up URL by hyphen, not not underscore or nospace, so why don't they do the same way as ID or class name?
The bottomline is: it didn't hurt anything.
I usually rule out 1. since it can cause confusion about case sensitivity.
Similarly, in programming hyphens are usually used as a minus operator. I favour underscores for such usage, since I feel it avoids any confusion, and any potential for clashes if you need to process the data with another programming language.
It is obvious, a spider like Google can split up URL by hyphen, not not underscore or nospace, so why don't they do the same way as ID or class name?
This shouldn't have anything to do with SEO. Google doesn't show code in its index, albeit they may look at it behind the scenes.
Regarding the hyphen, why should anyone care whether Google can parse words in a div id name? Are we trying to rank on "main" or on "body"? ;)