格 千格 KiloCell

HTML Entity Reference Table

Loading entity data...
Select Copy Format
Character
Name of entity
Hexadecimal

What is an HTML entity?

Some characters in HTML have special meanings, such as less than a mark < indicates the beginning of the label. If these characters are used directly in text, the browser mistook them as HTML code, which leads to a page rendering error or security hazard. HTML Entity The mechanisms of diversion that exist to address this problem are the ones that exist.

A standard HTML entity usually consists of three parts: a sum number (A/C.1/62/L.16) & ), the name or number of an entity, and a semi-colon () ; )。 For example, copyrighted symbols © The name of the entity is &copy; , number is &#169; 。

Why does the HTML entity need to be used?

Avoiding HTML conflicts

The most common use is to transpose characters that are decrypted by browsers as HTML tags, such as < 、 > and & 。 By Usage &lt; and &gt; , you can safely display the code example on the page without being deciphered.

2. Prevention of XSS attacks

Convert special characters to HTML when processing user input Entities are an important means of preventing cross-site attacks (XSS). By transposition, the malicious scripts <script> The label will be made plain text and cannot be executed in the user ' s browser.

3. Display invisible characters or special symbols

Many characters cannot be entered directly through the normal keyboard or are not present in some codes (e.g. early ASCII). HTML Entities allow developers to insert symbols through simple codes, such as mathematical formulae, currency symbols, Greek alphabets and technical symbols.

Detailed classification of entities commonly used HTML

  • Base transition: Organisation &amp; (&), &lt; (<), &gt; (>), &quot; ("), &apos; (')。 This is the core five transposers of Web development.
  • Mathematical operators: Covered &plusmn; (±), &times; (×), &divide; (÷), &infin; (∞) etc., suitable for use in educational or scientific-type websites.
  • Currency symbol: Except for the usual. &yen; ( grunts ) and &euro; (u) Supporting the global multi-currency conversion.
  • Arrows and pointed: &larr; (←), &rarr; ( ) The symbol is very useful in UI navigation design.

Use entities in CSS and JavaScript

Although HTML entities are mainly used for HTML documents, there are also corresponding programs in other front-end technologies:

  • CSS: Yes. content Properties use a backslash to transpose, for example content: "\00A9"; 。
  • JavaScript: Use Unicode conversion sequence, e. g. console.log("\u00A9"); 。

Recommendations for best practices

In modern Web development, due to UTF-8 The code is popular, and many symbols can be written directly in the source code. However, we strongly recommend the use of HTML entities in the following scenarios:

  1. Code presentation: Displays HTML or XML Snippets.
  2. User-generated content: The text entered by the user must be re-referenced when replaying the page.
  3. Special space: Use &nbsp; Controls do not change spaces to ensure layout stability.
Copyed to clipboard