Page 1 of 1

Are dashes/hyphens safe for ID names?

Posted: Mon Jan 11, 2010 5:51 am
by Sindarin
I must say I am really confused, I have been reading articles on what is allowed and not when giving HTML elements, IDs.

I want to use:
<input type="checkbox" class="checkbox" id="my-option" name="my-option" />

Is it safe to use dash/hyphen in the ID? It doesn't generate an error for me but I've read some people saying JavaScript could treat "my-option" as "my minus option".

Re: Are dashes/hyphens safe for ID names?

Posted: Mon Jan 11, 2010 9:17 am
by Charles256
Not if it's in quotes as it should be. At least to the best of my knowledge. If someone knows otherwise a demo would be great.