In the latest version of Selectors Level 4:
The class selector is given as a full stop (. U+002E) immediately followed by an identifier.
An ID selector consists of a “number sign” (U+0023, #) immediately followed by the ID value, which must be a CSS identifier.
In the identifier link above:
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); cannot start with a digit, two hyphens, or a hyphen followed by a digit.
However, in that same spec, the Grammar part:
<class-selector> = '.' <ident-token>
<id-selector> = <hash-token>
As you can see from the token links above, the syntax diagram explicitly specifies that a CSS identifer may begin with two hyphens, and the grammar of an ID selector contradicts with the grammar of a hash-token.
Which definitions should I follow?
UPDATE:
I missed a line in the bottom of the Grammar section:
In <id-selector>, the <hash-token>’s value must be an identifier.