CSS <custom-ident> Data Type
<custom-ident> is a generic data type that represents a custom identifier defined by the author of the style sheet.
Some CSS properties accept a
<custom-ident> value so that you can create an arbitrary value that serves as an identifier. When you see
<custom-ident> (including the
>) anywhere in the CSS specifications, this refers to the fact that the value can be an arbitrary author-defined identifier.
For example, the
counter-reset property accepts the following values.
So you could write something like this:
Here's a working example:
So in this example, I created two
<custom-ident>s; one called
h1-counter and another called
h2-counter. And I used
counter-reset to set/change the values of those identifiers as required.
<custom-ident> can be any valid CSS identifier that would not be misinterpreted as a pre-defined keyword in that property's value definition.
<custom-ident> can include the following characters:
- Any alphanumeric character (
- Any decimal digit (
- A hyphen (
- An underscore (
- May contain other ASCII characters if escaped with backslash (
- A Unicode character (in the format of a backslash followed by one to six hexadecimal digits, which represents its Unicode code point).
<custom-ident> must also adhere to the following rules:
- Must not use a digit as the first character unless it is escaped.
- Must not start with a hyphen followed by a decimal digit.
- Must not start with two hyphens.
<custom-ident>s are case sensitive. Therefore,
MYEXAMPLEare four completely unrelated identifiers.
- The CSS-wide keywords are not valid
<custom-ident>s. Therefore, do not use
unsetas an identifier.
defaultkeyword is not a valid
- Excluded keywords are excluded in all ASCII case permutations. So
DEFAULTshould not be used, for example.
- Do not wrap your
<custom-ident>s within quotes. If you do, they will be interpreted as strings instead of an identifier.
Here are some examples of valid
<custom-ident>data type is defined in CSS Values and Units Module Level 3 (W3C Candidate Recommendation, 29 September 2016)
- CSS identifiers are also defined in Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification (W3C Recommendation 07 June 2011)