当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML 实体字符

HTML
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML 属性
HTML 事件
HTML URL-encode
HTML Web服务器
HTML 摘要
HTML 实例
标签列表
标准属性
事件属性
ASCII码
特殊字符
HTTP状态消息

HTML 实体字符


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1119 ::
收藏到网摘: n/a

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中显示(<)这个字符,我们就必须使用实体字符。


Character Entities
实体字符

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: &lt; or &#60;
要显示小于符号就得在HTML中写:&lt; 或者&#60;

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浏览器)


Non-breaking Space
不换行间隔

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 &nbsp; character entity.
一般HTML会给你的文本除去间隔,如果你在文本中有10格间隔,那么HTML就会去掉其中的9个。想添加间隔的话就得使用&nbsp; 字符。


The Most Common Character Entities:
一些很常用的实体字符:

Result
结果
Description
描述
Entity Name
实体名
Entity Number
实体数
  non-breaking space
非换行间隔
&nbsp; &#160;
< less than
小于
&lt; &#60;
> greater than
大于
&gt; &#62;
& ampersand
“&” 号
&amp; &#38;
" quotation mark
双引号
&quot; &#34;
' apostrophe 
单引号
&apos; (does not work in IE)
IE不支持
&#39;

Some Other Commonly Used Character Entities:
其它常用字符实体:

Result
结果
Description
描述
Entity Name
实体名
Entity Number
实体数
¢ cent
&cent; &#162;
£ pound
&pound; &#163;
¥ yen
&yen; &#165;
§ section
部门
&sect; &#167;
© copyright
版权
&copy; &#169;
® registered trademark
注册商标
&reg; &#174;
× multiplication
&times; &#215;
÷ division
&divide; &#247;


To see a full list of HTML character entities go to our HTML Entities Reference.
查看完整的实体字符

评论 (0) All

登陆 | 还没注册?