我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。
An HTML entity is a piece of text ("string") that begins with the ampersand (&) character and ends with the semicolon (;) character. Often, users employ entities to display characters that are normally interpreted as HTML code, invisible characters such as the non-breaking space, or characters that are difficult to type with a standard keyboard.
Many characters have memorable entities. For example, the entity for the copyright symbol (©) is ©. For characters that don't have a memorable entity, you can use a numeric character reference, such as — or —. To get the numeric character reference, you can use a tool.
HTML reserves four characters for its syntax:
- &
- the ampersand
- <
- the less-than sign
- >
- the greater-than sign
- "
- the straight double-quote character
Instead of displaying these characters as text, browsers interpret them according to special rules, or "parse" them. For instance, if you use the less-than (<) sign in HTML, the browser interprets the following text as a tag. To display the characters as text, known as "escaping" the characters, replace them with their corresponding character entities in the following table.
| Character | Entity | Note |
|---|---|---|
| & | & |
Interpreted as the beginning of an entity or character reference. |
| < | < |
Interpreted as the beginning of a tag |
| > | > |
Interpreted as the ending of a tag |
| " | " |
Interpreted as the beginning and end of an attribute's value. |