HTML 实体用于表示在 HTML 保留的字符或具有特殊含义的字符。这也可用于显示标准键盘上不可用的字符。实体以 &('&') 开头,以分号(';') 结尾。
例如:
- >(大于)= >
- <(小于)= <
HTML 字符实体名称和代码
您不能在 HTML 文本中使用大于和小于符号或尖括号,因为浏览器会以不同的方式处理它们,并尝试绘制与 HTML 标记相关的含义。
我们可以使用实体名称或实体编号来显示保留的 HTML 字符,即要显示小于号 (<),我们必须写成:<或 <
HTML 处理器必须支持下表中列出的以下五个特殊字符:
| 字符 | 描述 | 实体名称 | 数字代码 |
|---|---|---|---|
| " | 双引号 | " | " |
| ' | 单引号 | ' | ' |
| & | 与号 | & | & |
| < | 小于 | < | < |
| > | 大于 | > | > |
HTML 不间断空格名称和代码
HTML 中,您可以使用“ ”实体在元素和文本之间添加空格。与空格键给出的空间不同,此空间不会中断为新行。
- 用“ ”分隔的两个单词即使在行尾也会粘在一起。
- 如果您使用空格键在文本中写入 5 个空格,浏览器将仅添加 1 个空格。要向文本添加实空格,可以使用“ ”字符实体。
HTML 实体示例
让我们看一下下面的例子,我们在代码中显示一些字符实体和转义符号:
<!DOCTYPE html>
<html>
<head>
<title>HTML Character Entities</title>
</head>
<body>
<h1>HTML Character Entities</h1>
<table>
<tr>
<th>Symbol</th>
<th>Entity</th>
</tr>
<tr>
<td>"</td>
<td>&quot;</td>
</tr>
<tr>
<td>&</td>
<td>&amp;</td>
</tr>
</tr>
<tr>
<td>'</td>
<td>&apos;</td>
</tr>
</table>
This is example of
&nbsp; character
</body>
</html>
HTML 4.0 中还有一长串特殊字符。为了使它们出现在文档中,您可以使用数字代码或实体名称。例如,要插入版权符号,可以使用以下任一方法:
© 2024
or
© 2024
or
© 2024
ISO 8859-1 符号实体名称和代码
以下是下面列出的 ISO 8859-1 符号实体:
| 结果 | 描述 | 实体名称 | 数字代码 |
|---|---|---|---|
| 不间断空格 | |   | |
| ¡ | 倒置感叹号 | ¡ | ¡ |
| ¤ | 货币 | ¤ | ¤ |
| ¢ | 分(辅币单位) | ¢ | ¢ |
| £ | 磅 | £ | £ |
| ¥ | 日元 | ¥ | ¥ |
| ¦ | 垂直杆断裂 | ¦ | ¦ |
| § | 部分 | § | § |
| ¨ | 间距偏差 | ¨ | ¨ |
| © | 版权 | © | © |
| ª | 阴性序数指示符 | ª | ª |
| « | 角引号(左) | « | « |
| ¬ | 否定 | ¬ | ¬ |
| | 软连字符 | ­ | ­ |
| ® | 注册商标 | ® | ® |
| ™ | 商标 | ™ | ™ |
| ¯ | 间距宏 | ¯ | ¯ |
| ° | 度 | ° | ° |
| ± | 正或负 | ± | ± |
| ² | 上标2 | ² | ² |
| ³ | 上标3 | ³ | ³ |
| ´ | 间距急性 | ´ | ´ |
| µ | 微观的 | µ | µ |
| ¶ | 段落 | ¶ | ¶ |
| · | 中间点 | · | · |
| ¸ | 雪松间距 | ¸ | ¸ |
| ¹ | 上标1 | ¹ | ¹ |
| º | 阳性序数指示符 | º | º |
| » | 角引号(右) | » | » |
| ¼ | 分数1/4 | ¼ | ¼ |
| ½ | 分数1/2 | ½ | ½ |
| ¾ | 分数3/4 | ¾ | ¾ |
| ¿ | 倒置问号 | ¿ | ¿ |
| × | 增加 | × | × |
| ÷ | 除(法) | ÷ | ÷ |
ISO 8859-1 字符实体名称和代码
让我们看一下下面列出的 ISO 8859-1 字符实体:
| 结果 | 描述 | 实体名称 | 数字代码 |
|---|---|---|---|
| À | capital a, grave accent | À | À |
| Á | capital a, acute accent | Á | Á |
| Â | capital a, circumflex accent | Â | Â |
| Ã | capital a, tilde | Ã | Ã |
| Ä | capital a, umlaut mark | Ä | Ä |
| Å | capital a, ring | Å | Å |
| Æ | capital ae | Æ | Æ |
| Ç | capital c, cedilla | Ç | Ç |
| È | capital e, grave accent | È | È |
| É | capital e, acute accent | É | É |
| Ê | capital e, circumflex accent | Ê | Ê |
| Ë | capital e, umlaut mark | Ë | Ë |
| Ì | capital i, grave accent | Ì | Ì |
| Í | capital i, acute accent | Í | Í |
| Î | capital i, circumflex accent | Î | Î |
| Ï | capital i, umlaut mark | Ï | Ï |
| Ð | capital eth, Icelandic | Ð | Ð |
| Ñ | capital n, tilde | Ñ | Ñ |
| Ò | capital o, grave accent | Ò | Ò |
| Ó | capital o, acute accent | Ó | Ó |
| Ô | capital o, circumflex accent | Ô | Ô |
| Õ | capital o, tilde | Õ | Õ |
| Ö | capital o, umlaut mark | Ö | Ö |
| Ø | capital o, slash | Ø | Ø |
| Ù | capital u, grave accent | Ù | Ù |
| Ú | capital u, acute accent | Ú | Ú |
| Û | capital u, circumflex accent | Û | Û |
| Ü | capital u, umlaut mark | Ü | Ü |
| Ý | capital y, acute accent | Ý | Ý |
| Þ | capital THORN, Icelandic | Þ | Þ |
| ß | small sharp s, German | ß | ß |
| à | small a, grave accent | à | à |
| á | small a, acute accent | á | á |
| â | small a, circumflex accent | â | â |
| ã | small a, tilde | ã | ã |
| ä | small a, umlaut mark | ä | ä |
| å | small a, ring | å | å |
| æ | small ae | æ | æ |
| ç | small c, cedilla | ç | ç |
| è | small e, grave accent | è | è |
| é | small e, acute accent | é | é |
| ê | small e, circumflex accent | ê | ê |
| ë | small e, umlaut mark | ë | ë |
| ì | small i, grave accent | ì | ì |
| í | small i, acute accent | í | í |
| î | small i, circumflex accent | î | î |
| ï | small i, umlaut mark | ï | ï |
| ð | small eth, Icelandic | ð | ð |
| ñ | small n, tilde | ñ | ñ |
| ò | small o, grave accent | ò | ò |
| ó | small o, acute accent | ó | ó |
| ô | small o, circumflex accent | ô | ô |
| õ | small o, tilde | õ | õ |
| ö | small o, umlaut mark | ö | ö |
| ø | small o, slash | ø | ø |
| ù | small u, grave accent | ù | ù |
| ú | small u, acute accent | ú | ú |
| û | small u, circumflex accent | û | û |
| ü | small u, umlaut mark | ü | ü |
| ý | small y, acute accent | ý | ý |
| þ | small thorn, Icelandic | þ | þ |
| ÿ | small y, umlaut mark | ÿ | ÿ |
浏览器支持的其他实体
以下是浏览器支持的其他实体:
| 结果 | 描述 | 实体名称 | 数字代码 |
|---|---|---|---|
| Œ | capital ligature OE | Œ | Œ |
| œ | small ligature oe | œ | œ |
| Š | capital S with caron | Š | Š |
| š | small S with caron | š | š |
| Ÿ | capital Y with diaeres | Ÿ | Ÿ |
| ˆ | modifier letter circumflex accent | ˆ | ˆ |
| ˜ | small tilde | ˜ | ˜ |
| en space |   |   | |
| em space |   |   | |
| thin space |   |   | |
| | zero width non-joiner | ‌ | ‌ |
| | zero width joiner | ‍ | ‍ |
| | left-to-right mark | ‎ | ‎ |
| | right-to-left mark | ‏ | ‏ |
| – | en dash | – | – |
| — | em dash | — | — |
| ‘ | left single quotation mark | ‘ | ‘ |
| ’ | right single quotation mark | ’ | ’ |
| ‚ | single low-9 quotation mark | ‚ | ‚ |
| “ | left double quotation mark | “ | “ |
| ” | right double quotation mark | ” | ” |
| „ | double low-9 quotation mark | „ | „ |
| † | dagger | † | † |
| ‡ | double dagger | ‡ | ‡ |
| … | horizontal ellipsis | … | … |
| ‰ | per mille | ‰ | ‰ |
| ‹ | single left-pointing angle quotation | ‹ | ‹ |
| › | single right-pointing angle quotation | › | › |
| € | euro | € | € |

