IDs and classes must be valid identifiers.
Identifiers are listed like so in the specification:
ident -?{nmstart}{nmchar}*
So an optional -
sign, followed by nmstart
, followed by any number of nmchar
s.
The one we're interested in is nmstart
, but I'll also list nmchar
:
nmstart [_a-z]|{nonascii}|{escape}
nmchar [_a-z0-9-]|{nonascii}|{escape}
And just for completeness:
nonascii [240-377]
escape {unicode}|\[^
f0-9a-f]
unicode \{h}{1,6}(
|[
f])?
Okay, so with all that out of the way, notice how nmstart
does not include 0-9
or -
. This means that IDs and classes cannot start with a number according to the CSS specification. In fact, they can't even start with -1
. Or two hyphens.
This is why they are not recognised in your code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…