From bd74b8a8222517dead9def675a499dcf1dc30328 Mon Sep 17 00:00:00 2001 From: Hoarfroster Date: Fri, 10 Jan 2025 15:26:50 +0800 Subject: [PATCH] Add glossary term 'escaping text' (#37444) * Add glossary term 'escaping text' * Apply suggestions from code review Co-authored-by: Estelle Weyl * Apply suggestions from code review Co-authored-by: Joshua Chen * Update files/en-us/glossary/escaping_text/index.md Co-authored-by: Joshua Chen * Apply suggestions from code review * fix: name changes * Update index.md * Update files/en-us/glossary/escape_character/index.md Co-authored-by: Joshua Chen * Apply suggestions from code review Co-authored-by: Estelle Weyl --------- Co-authored-by: Estelle Weyl Co-authored-by: Joshua Chen --- .../glossary/character_reference/index.md | 12 ++++++++-- .../en-us/glossary/escape_character/index.md | 23 +++++++++++++++++++ files/en-us/web/css/ident/index.md | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 files/en-us/glossary/escape_character/index.md diff --git a/files/en-us/glossary/character_reference/index.md b/files/en-us/glossary/character_reference/index.md index 072822ed0459923..26e40214fa3f89c 100644 --- a/files/en-us/glossary/character_reference/index.md +++ b/files/en-us/glossary/character_reference/index.md @@ -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. @@ -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 `<`, because the Unicode code point for the symbol is `U+0003C`, and `3C` hexadecimal is 60 in decimal. - **Hexadecimal numeric character reference** @@ -50,3 +50,11 @@ A very small subset of useful named character references along with their unicod | ° | `°` | 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")}} diff --git a/files/en-us/glossary/escape_character/index.md b/files/en-us/glossary/escape_character/index.md new file mode 100644 index 000000000000000..a2073c3ca7372de --- /dev/null +++ b/files/en-us/glossary/escape_character/index.md @@ -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 `<`, `<`, or `<`. +- 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 diff --git a/files/en-us/web/css/ident/index.md b/files/en-us/web/css/ident/index.md index d5bcae0bf6dbd78..859c071d2937367 100644 --- a/files/en-us/web/css/ident/index.md +++ b/files/en-us/web/css/ident/index.md @@ -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.