| Learn | HTML - Classes and IDs - Acceptable values |
|---|
Acceptable Values For an IDThe only restrictions on the value of an
So the value can be all digits, just one digit, just punctuation characters, include special characters, whatever. Just no whitespace. So these are valid: This is invalid: This is also invalid, when included in the same document: An
Referring to the first group of examples in the HTML5 section above, only one is valid: These are also valid: Again, if it doesn't start with a letter (uppercase or lowercase), it's not valid. For a ClassThe rules for classes are essentially the same as for an Referring to the examples above, although this is not valid in the same document: This is perfectly okay: Important Note: How ID and Class values are treated outside of HTMLKeep in mind that the rules and examples above apply within the context of HTML. Using numbers, punctuation or special characters in the value of an For example, although the following ... it is invalid in CSS: 4.1.3 Characters and case (opens new window) 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 (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. (emphasis added) In most cases you may be able to escape characters in contexts where they have restrictions or special meaning. W3C References |
Read Article
https://develop.horje.com/learn/1434/reference