当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML 实体字符
Some characters like the < character, have a special meaning in HTML, and therefore cannot be used in the text.
有些字符,像(<)这类的,对HTML来说是有特殊意义的,所以这些字符是不允许在文本中使用的。
To display a less than sign (<) in HTML, we have to use a character entity.
要在HTML中显示(<)这个字符,我们就必须使用实体字符。
Some characters have a special meaning in HTML, like the less than sign (<) that defines the start of an HTML tag. If we want the browser to actually display these characters we must insert character entities in the HTML source.
有一些字符对HTML来讲是有特殊意义的,像小于符号(<)是用来定义HTML头标签的。如果我们想在浏览器中显示这类字符就必须在HTML代码中插入实体字符。
A character entity has three parts: an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;).
一个实体字符有三个部分:一个(&)符号,一个特殊符号名称或一个#加上一个特殊数字,最后是一个分号(;)。
To display a less than sign in an HTML document we must write: < or <
要显示小于符号就得在HTML中写:< 或者<
The advantage of using a name instead of a number is that a name is easier to remember. The disadvantage is that not all browsers support the newest entity names, while the support for entity numbers is very good in almost all browsers.
使用名称的好处是它比用数字来的方便记忆。但不是所有浏览器都支持最新的一些实体字符,不像实体字符那样很好的被所有浏览器做支持。
Note that the entities are case sensitive.
注意 实体字符需要注意大小写。
This example lets you experiment with character entities: Character Entities IE only
这个例子是让你来试验这些实体字符的(只限IE浏览器)
The most common character entity in HTML is the non-breaking space.
在HTML中最普通的实体字符就是不换行间隔了。
Normally HTML will truncate spaces in your text. If you write 10 spaces in your text HTML will remove 9 of them. To add spaces to your text, use the character entity.
一般HTML会给你的文本除去间隔,如果你在文本中有10格间隔,那么HTML就会去掉其中的9个。想添加间隔的话就得使用 字符。
Result 结果 | Description 描述 | Entity Name 实体名 | Entity Number 实体数 |
---|---|---|---|
non-breaking space 非换行间隔 | |   | |
< | less than 小于 | < | < |
> | greater than 大于 | > | > |
& | ampersand “&” 号 | & | & |
" | quotation mark 双引号 | " | " |
' | apostrophe 单引号 | ' (does not work in IE) IE不支持 | ' |
Result 结果 | Description 描述 | Entity Name 实体名 | Entity Number 实体数 |
---|---|---|---|
¢ | cent 分 | ¢ | ¢ |
£ | pound 磅 | £ | £ |
¥ | yen 元 | ¥ | ¥ |
§ | section 部门 | § | § |
© | copyright 版权 | © | © |
® | registered trademark 注册商标 | ® | ® |
× | multiplication 乘 | × | × |
÷ | division 除 | ÷ | ÷ |
To see a full list of HTML character entities go to our HTML Entities Reference.
查看完整的实体字符