Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wbamberg committed Jul 2, 2024
1 parent c722c2e commit 5618c77
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions files/en-us/web/css/ident/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: <ident>
slug: Web/CSS/ident
page-type: css-type
spec-urls: https://drafts.csswg.org/css-values/#css-identifier
spec-urls: https://drafts.csswg.org/css-values/#typedef-ident
---

{{CSSRef}}
Expand All @@ -13,11 +13,11 @@ The **`<ident>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS

A CSS identifier consists of one or more characters, which can be any of the following:

- any ASCII character in the ranges `A-Z` and `a-z`
- any {{glossary("ASCII")}} character in the ranges `A-Z` and `a-z`
- any decimal digit (`0` to `9`)
- a hyphen (`-`)
- an underscore (`_`)
- any other Unicode character `U+00A0` and higher (that is, any other non-ASCII Unicode character)
- any other {{glossary("Unicode")}} character `U+00A0` and higher (that is, any other non-ASCII Unicode character)
- an [escaped character](escaping_characters)

Additionally, an identifier must not start with an unescaped digit, and must not start with an unescaped hyphen followed by an unescaped digit.
Expand All @@ -26,39 +26,39 @@ Note that `id1`, `Id1`, `iD1` and `ID1` are all different identifiers because th

### Escaping characters

You can escape a character by adding a backslash (\) in front of the character. Any character, except the hexadecimal digits `0-9`, `a-f`, and `A-F`, can be escaped in this way. For example, `&` can be escaped as `\&`.
Escaping a character means representing it in a way that changes the way it is interpreted by a software system. In CSS, you can escape a character by adding a backslash (`\`) in front of the character. Any character, except the hexadecimal digits `0-9`, `a-f`, and `A-F`, can be escaped in this way. For example, `&` can be escaped as `\&`.

You can also escape any character with a backslash followed by the character's Unicode {{glossary("code point")}} represented by one to six hexadecimal digits. For example, `&` can be escaped as `\26`. In this usage, if the escaped character is followed by a hexadecimal digit, do one of the following:

- a space or other whitespace character must be placed after the Unicode code point, or:
- the Unicode code point must be given in full, with all six digits.
- Place a space or other whitespace character after the Unicode code point.
- Provide the full six-digit Unicode code point of the character being escaped.

For example, the string `&123` can be escaped as `\26 123` (with a whitespace) or `\000026123` (with the six-digit Unicode code point of `&`) to ensure that `123` is not considered as part of the escape pattern.
For example, the string `&123` can be escaped as `\26 123` (with a whitespace) or `\000026123` (with the six-digit Unicode code point for `&`) to ensure that `123` is not considered as part of the escape pattern.

## Examples

### Valid identifiers

```plain example-good
nono79 A mix of alphanumeric characters and numbers
ground-level A mix of alphanumeric characters and a dash
nono79 /* A mix of alphanumeric characters and numbers */
ground-level /* A mix of alphanumeric characters and a dash */
-test /* A hyphen followed by alphanumeric characters */
--toto A custom-property like identifier
_internal An underscore followed by alphanumeric characters
\22 toto An escaped character followed by a sequence of alphanumeric characters
--toto /* A custom-property like identifier */
_internal /* An underscore followed by alphanumeric characters */
\22 toto /* An escaped character followed by alphanumeric characters */
\000022toto /* Same as the previous example */
bili\.bob A correctly escaped period
🔥123 A non-ASCII character followed by numbers
bili\.bob /* A correctly escaped period */
🔥123 /* A non-ASCII character followed by numbers */
```

### Invalid identifiers

```plain example-bad
34rem /* Must not start with a decimal digit */
-12rad It must not start with a dash followed by a decimal digit.
bili.bob ASCII characters apart from alphanumerics must be escaped.
-12rad /* Must not start with a dash followed by a decimal digit */
bili.bob /* ASCII characters apart from alphanumerics must be escaped */
'bilibob' /* Treated as a string */
"bilibob" This would be a {{CSSxRef("&lt;string&gt;")}}.
"bilibob" /* Treated as a string */
```

## Specifications
Expand Down

0 comments on commit 5618c77

Please sign in to comment.