<div class="article-intro" id="content">
<h1>HTML <span class="color_h1">字符实体</span>
HTML 中的预留字符必须被替换为字符实体。
一些在键盘上找不到的字符也可以使用字符实体来替换。
HTML 实体
在 HTML 中,某些字符是预留的。
在 HTML 中不能使用小于号(<)和大于号(>),这是因为浏览器会误认为它们是标签。
如果希望正确地显示预留字符,我们必须在 HTML 源代码中使用字符实体(character entities)。 字符实体类似这样:
&entity_name;
或
&# entity_number;如需显示小于号,我们必须这样写:< 或 < 或 <
提示: 使用实体名而不是数字的好处是,名称易于记忆。不过坏处是,浏览器也许并不支持所有实体名称(对实体数字的支持却很好)。
不间断空格(Non-breaking Space)
HTML 中的常用字符实体是不间断空格( )。
浏览器总是会截短 HTML 页面中的空格。如果您在文本中写 10 个空格,在显示该页面之前,浏览器会删除它们中的 9 个。如需在页面中增加空格的数量,您需要使用 字符实体。
结合音标符
发音符号是加到字母上的一个"glyph(字形)"。
一些变音符号, 如 尖音符 ( ̀) 和 抑音符 ( ́) 。
变音符号可以出现字母的上面和下面,或者字母里面,或者两个字母间。
变音符号可以与字母、数字字符的组合来使用。
以下是一些实例:
音标符 | 字符 | Construct | 输出结果 |
---|---|---|---|
̀ | a | à | à |
́ | a | á | á |
̂ | a | â | â |
̃ | a | ã | ã |
̀ | O | Ò | Ò |
́ | O | Ó | Ó |
̂ | O | Ô | Ô |
̃ | O | Õ | Õ |
HTML字符实体
实体名称对大小写敏感! |
<tbody><tr>
<th style="width:20%">显示结果</th>
<th style="width:20%">描述</th>
<th style="width:30%">实体名称</th>
<th style="width:30%">实体编号</th>
</tr>
<tr>
<td> </td>
<td>空格</td>
<td>&nbsp;</td>
<td>&#160;</td>
</tr>
<tr>
<td><</td>
<td>小于号</td>
<td>&lt;</td>
<td>&#60;</td>
</tr>
<tr>
<td>></td>
<td>大于号</td>
<td>&gt;</td>
<td>&#62;</td>
</tr>
<tr>
<td>&</td>
<td>和号</td>
<td>&amp;</td>
<td>&#38;</td>
</tr>
<tr>
<td>"</td>
<td>引号</td>
<td>&quot;</td>
<td>&#34;</td>
</tr>
<tr>
<td>'</td>
<td>撇号 </td>
<td>&apos; (IE不支持)</td>
<td>&#39;</td>
</tr>
<tr>
<td>¢</td>
<td>分</td>
<td>&cent;</td>
<td>&#162;</td>
</tr>
<tr>
<td>£</td>
<td>镑</td>
<td>&pound;</td>
<td>&#163;</td>
</tr>
<tr>
<td>¥</td>
<td>人民币/日元</td>
<td>&yen;</td>
<td>&#165;</td>
</tr>
<tr>
<td>€</td>
<td>欧元</td>
<td>&euro;</td>
<td>&#8364;</td>
</tr>
<tr>
<td>§</td>
<td>小节</td>
<td>&sect;</td>
<td>&#167;</td>
</tr>
<tr>
<td>©</td>
<td>版权</td>
<td>&copy;</td>
<td>&#169;</td>
</tr>
<tr>
<td>®</td>
<td>注册商标</td>
<td>&reg;</td>
<td>&#174;</td>
</tr>
<tr>
<td>™</td>
<td>商标</td>
<td>&trade;</td>
<td>&#8482;</td>
</tr>
<tr>
<td>×</td>
<td>乘号</td>
<td>&times;</td>
<td>&#215;</td>
</tr>
<tr>
<td>÷</td>
<td>除号</td>
<td>&divide;</td>
<td>&#247;</td>
</tr>
虽然 html 不区分大小写,但实体字符对大小写敏感。
查看本站完整的HTML实体:请点击 HTML 实体参考手册。
</div>
</div>