I'm pretty sure it's just alpha-numeric plus underscore and hypen, but my google-foo is failing me.

3 answers

This was chosen as the best answer

Finally found it. http://www.w3.org/TR/html4/types.html#h-6.2

"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")."

Update: As another answerer mentioned, it's never good to assume that just because it's written in the specs that every browser supports it (or, as in this case, that the definition mentioned strictly applies to the matter at hand). In other words, test it in the environments in which you'll be using these ids to be sure.

Answered about 10 years ago by Michael Todd

Just because you find something in a W3.org document doesn't mean it applies to current web development. Those are merely specs and not necessarily supported by all browsers. Try using a colon in your ID name inside of your style sheet and see if that works. That is a reserved character for things like ":after, :hover". I believe that part of the spec might be something that applies s to XML. The rule goes that you must start an ID or Class name with a letter then followed by a another letter, number, underscore or hyphen.

Answered about 10 years ago by Efficient Pixel

Using a colon (or period) in an ID is actually possible to match in a CSS selector

Answered about 10 years ago by Chriztian Steinmeier