跳到主要内容
uencoder

HTML Entity 完整 List

Named 和 numeric 字符参考为 HTML, including five 强制 entities 和常见 symbols.

Mandatory Entities

HTML defines five characters that must always be escaped when they appear in text content or attribute values to prevent parsing ambiguity. These entities avoid premature tag closure and attribute boundary confusion. Using them consistently prevents XSS injection points from forming in templates. Numeric references provide a fallback when named entities are unavailable in a given parser.

&
Ampersand, entity reference introducer
& → &
<
Less-than sign, tag opener
< → &lt;
&gt;
Greater-than sign, tag closer
> → &gt;
&quot;
Double quote, attribute delimiter
" → &quot;
&apos;
Apostrophe, single-quote attribute delimiter
' → &apos;

Numeric References

Numeric character references address any Unicode code point without relying on a named entity table. Decimal references use '&#' followed by the code point and a semicolon, while hexadecimal references use '&#x' with hex digits. Both forms resolve to the same character, but hex is more compact for large code points. Parsers must handle surrogate pairs correctly when the code point exceeds the BMP.

Common Symbol Entities

Beyond the mandatory five, many symbols have named entities for convenience in authoring. Mathematical operators, currency symbols, and typographic marks such as the non-breaking space and em dash are frequently encoded. The HTML5 specification lists over 2,000 named entities derived from SVG and MathML sets. Relying on named entities improves readability of source but numeric references are more portable across XML dialects.

相关工具

参考链接