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


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

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
一些很常用的特殊字符:

ResultDescriptionEntity NameEntity Number
 非换行空格&nbsp; 
<小于&lt;<
>大于&gt;>
&“&” 号&amp;&
"双引号&quot;"
'单引号 &apos; (IE不支持)'

Some Other Commonly Used Character Entities
其他一些:

ResultDescriptionEntity NameEntity Number
cent分&cent;¢
£pound镑&pound;£
¥yen&yen;¥
§section&sect;§
©copyright版权&copy;©
®registered 注册trademark&reg;®
×multiplication乘&times;×
÷division除&divide;÷

转载于:https://www.cnblogs.com/sherrys/archive/2006/11/01/546367.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值