That's the difference in HTML4 vs HTML5.
As this answer says, id's in HTML4 were highly restrictive on what is allowed.
A valid id in HTML4 as per the spec,
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 (".")
.
HTML5 is a lot more relaxed with id's. A valid id as per the HTML5 spec,
must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.
Since browsers are transitioning to HTML5 (most have already implemented these basics), you might find that most modern browsers will adhere to the HTML5 way of defining ids. Still the best way is to test it out or have backing documentation to know exactly which browsers do and don't work.