← 速查表

HTML 实体速查表

有些字符在 HTML 里有特殊含义。想把它们当作文本显示,就要写实体:一个 &、名称或编号、一个分号。

保留字符 — 内容里必须转义

实体数字形式渲染结果
&lt;&#60;<
&gt;&#62;>
&amp;&#38;&
&quot;&#34;"
&apos;&#39;'

符号与排版

实体渲染结果
&nbsp;Non-breaking space
&copy; · &reg; · &trade;© · ® · ™
&mdash; · &ndash; · &hellip;— · – · …
&larr; · &rarr; · &darr; · &uarr;← · → · ↓ · ↑
&times; · &divide; · &minus;× · ÷ · −
&laquo; · &raquo;« · »
&bull; · &middot;• · ·
&euro; · &pound; · &yen;€ · £ · ¥

常见问题

When is escaping actually required?
Always escape < and & when they appear as text — < starts a tag the parser will try to execute, and & starts an entity the parser will try to resolve. Quotes matter inside attribute values.

Why does © render literally sometimes?
A missing semicolon. Browsers repair some entity typos, but only named entities with semicolons are guaranteed — write &copy; not &copy.

Entity vs numeric reference?
Named (&copy;) is readable; numeric (&#169;) covers every Unicode character, including ones with no named entity. Both are ASCII-safe for emails and old parsers.

别死记,直接用工具

Escape or unescape strings in the URL Encoder