Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glossary term 'escaping text' #37444

Merged
merged 9 commits into from
Jan 10, 2025
12 changes: 10 additions & 2 deletions files/en-us/glossary/character_reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ page-type: glossary-definition

{{GlossarySidebar}}

An {{glossary("HTML")}} **character reference** is a formatted pattern of characters that is used to represent another character in the rendered web page.
An {{glossary("HTML")}} **character reference** is an {{glossary("escape character", "escape sequence")}} of {{glossary("character", "characters")}} that is used to represent another character in the rendered web page.

Character references are used as replacements for characters that are reserved in HTML, such as the less-than (`<`) and greater-than (`>`) symbols used by the HTML parser to identify element {{Glossary('tag','tags')}}, or `"` or `'` within attributes, which may be enclosed by those characters.
They can also be used for invisible characters that would otherwise be impossible to type, including non-breaking spaces, control characters like left-to-right and right-to-left marks, and for characters that are hard to type on a standard keyboard.
Expand All @@ -21,7 +21,7 @@ There are three types of character references:

- **Decimal numeric character references**

- : These references start with `&#`, followed by one or more ASCII digits representing the base-ten integer that corresponds to the character's Unicode code point, and ending with `;`.
- : These references start with `&#`, followed by one or more ASCII digits representing the base-ten integer that corresponds to the character's {{glossary("Unicode")}} {{glossary("code point")}}, and ending with `;`.
For example, the decimal character reference for `<` is `&#60;`, because the Unicode code point for the symbol is `U+0003C`, and `3C` hexadecimal is 60 in decimal.

- **Hexadecimal numeric character reference**
Expand Down Expand Up @@ -50,3 +50,11 @@ A very small subset of useful named character references along with their unicod
| ° | `&deg;` | U+000B0 |

The full list of HTML named character references [can found in the HTML specification here](https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references).

## See also

- Related glossary terms:
- {{glossary("Character")}}
- {{glossary("Escape character")}}
- {{glossary("Code point")}}
- {{glossary("Unicode")}}
23 changes: 23 additions & 0 deletions files/en-us/glossary/escape_character/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Escape character
slug: Glossary/Escape_character
page-type: glossary-definition
---

{{GlossarySidebar}}

An **escape character** is a {{glossary("character")}} that causes one or more characters that follow it to be interpreted differently. This forms an **escape sequence**, which is often used to represent a character that has an alternative meaning when printed literally, such as the quote character in a string literal. Escape sequences can have other usages too, especially in [regular expressions](/en-US/docs/Web/JavaScript/Reference/Regular_expressions#escape_sequences).

- In JavaScript [regexes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape), [string literals](/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#string_literals), and [identifiers](/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers), we can use the backslash (`\`) to escape characters like `\'`, `\"`, `\u0026`, etc.
- In CSS identifiers, we can use the backslash (`\`) to escape characters like `\\`, `\n`, `\26`, etc. See [escape characters](/en-US/docs/Web/CSS/ident#escaping_characters) for more information.
- In HTML text content and attribute values, we can use {{glossary("character reference", "character references")}} like `&lt;`, `&#60;`, or `&#x3C;`.
- In {{glossary("URL", "URLs")}}, we can use the percent sign (`%`) to escape characters like `%20`, `%3C`, `%3E`, etc.

## See also

- Related glossary terms:
- {{glossary("Character")}}
- {{glossary("Character reference")}}
- {{glossary("Code point")}}
- [Escape character](https://en.wikipedia.org/wiki/Escape_character) on Wikipedia
- [Escape sequence](https://en.wikipedia.org/wiki/Escape_sequence) on Wikipedia
4 changes: 2 additions & 2 deletions files/en-us/web/css/ident/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Note that `id1`, `Id1`, `iD1` and `ID1` are all different identifiers because th

### Escaping characters

Escaping a character means representing it in a way that changes how 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 `\&`.
{{glossary("Escape character", "Escaping a character")}} means representing it in a way that changes how 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:
You can also escape any character with a backslash followed by the character's {{glossary("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:

- 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.
Expand Down
Loading