Hacker News new | past | comments | ask | show | jobs | submit login

Can class names begin with a hyphen followed by a number?

This SO answer says [1]:

> a name must begin with an underscore (_), a hyphen (-), or a letter(a–z), followed by any number of hyphens, underscores, letters, or numbers. There is a catch: if the first character is a hyphen, the second character must be a letter or underscore, and the name must be at least 2 characters long.

[1]: http://stackoverflow.com/a/449000

Which references the CSS Grammar spec [2].

[2]: http://www.w3.org/TR/CSS21/grammar.html#scanner




I think the best reference would be the actual (main) spec since the grammar spec says it is kind of a "superset" of the actual specification, i.e. not always strict enough. Identifiers are specified here: https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#va... (two hyphens at the start are also not allowed, in contrary to the "SO answer" cited).


That answer clearly states that -- is not allowed.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: