Html5 简明教程

HTML - Entities

HTML Entities 用于表示 HTML 中保留的字符或具有特殊含义的字符。还可以用来显示标准键盘上不可用的字符。实体以和号 ( & ) 开头,以分号 ( ; ) 结束。

HTML Entities are used to represent characters that are reserved in HTML or have special meanings. This can also used to display characters that are not available on a standard keyboard. Entities start with ampersand(&) and end with semi column(;).

For Example:

For Example:

  1. > (greater than) = >

  2. < (less than) = <

HTML Character Entities Name and Code

在 HTML 文本中不能使用大于号和小于号或尖括号,因为浏览器会以不同方式对待它们,并尝试绘制与 HTML 标签相关的含义。

You cannot use the greater than and less than signs or angle brackets within your HTML text because the browser will treat them differently and will try to draw a meaning related to HTML tag.

我们可以使用实体名称或实体数来显示保留的 HTML 字符,即要显示小于号 (<),我们必须编写:< 或 <

We can use entity names or entity numbers to display reserved HTML characters, ie to display a less than sign (<) we must write: < or <

HTML 处理器必须支持下表中列出的五个特殊字符。

HTML processors must support following five special characters listed in the table that follows.

Symbol

Description

Entity Name

Number Code

"

quotation mark

"

"

'

apostrophe

'

'

&

ampersand

&

&

<

less-than

<

<

>

greater-than

>

>

HTML Non Breaking Spaces Name and Code

在 HTML 中,可以使用 &nbsp 实体在元素和文本之间添加空格。与空格键提供的空格不同,此空格不会换行。

In HTML, You can add spaces between elements and texts using &nbsp entity. Unlike space given from space bar this space will not break into new line.

  1. Two words that are separated by &nbsp will stick together even at the end of line.

  2. If you write 5 spaces in your text using space bar, the browser will only add 1 space. To add real spaces to your text, you can use the &nbsp character entity.

Example of HTML Entities

我们看一下以下示例,在代码中显示一些字符实体和转义符号。

Let’s look into the following example we are displaying some character entities and the escape symbols in code.

<!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>&amp;quot;</td>
      </tr>
         <tr>
         <td>&</td>
         <td>&amp;amp;</td>
      </tr>
      </tr>
         <tr>
         <td>'</td>
         <td>&amp;apos;</td>
      </tr>
</table>
This is &nbsp; &nbsp; &nbsp; example of
&nbsp; &nbsp; &nbsp; &amp;nbsp; character
</body>
</html>

HTML 4.0 中还有一长串特殊字符。若要让这些字符出现在文档中,可以使用数字代码或实体名称。例如,要插入版权符号,可以使用以下两种方法之一:

There is also a long list of special characters in HTML 4.0. In order for these to appear in your document, you can use either the numerical codes or the entity names. For example, to insert a copyright symbol you can use either of the following:

&copy; 2007
or
&#169; 2007

ISO 8859-1 Symbol Entities Name and Code

以下是列出的 ISO 8859-1 符号实体:

Following are the ISO 8859-1 Symbol Entities that are listed below:

Result

Description

Entity Name

Number Code

non-breaking space

 

 

¡

inverted exclamation mark

¡

¡

¤

currency

¤

¤

¢

cent

¢

¢

£

pound

£

£

¥

yen

¥

¥

¦

broken vertical bar

¦

¦

§

section

§

§

¨

spacing diaeresis

¨

¨

©

copyright

©

©

ª

feminine ordinal indicator

ª

ª

«

angle quotation mark (left)

«

«

¬

negation

¬

¬

­

soft hyphen

­

­

®

registered trademark

®

®

trademark

¯

spacing macron

¯

¯

°

degree

°

°

±

plus-or-minus

±

±

²

superscript 2

²

²

³

superscript 3

³

³

´

spacing acute

´

´

µ

micro

µ

µ

paragraph

·

middle dot

·

·

¸

spacing cedilla

¸

¸

¹

superscript 1

¹

¹

º

masculine ordinal indicator

º

º

»

angle quotation mark (right)

»

»

¼

fraction 1/4

¼

¼

½

fraction 1/2

½

½

¾

fraction 3/4

¾

¾

¿

inverted question mark

¿

¿

×

multiplication

×

×

÷

division

÷

÷

ISO 8859-1 Character Entities Name and Code

以下是列出的 ISO 8859-1 字符实体:

Let’s look into the ISO 8859-1 Character Entities that are listed below:

Result

Description

Entity Name

Number Code

À

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

ÿ

ÿ

Other Entities Supported by Browsers

以下是浏览器支持的其他实体:

Following are the other Entities that are supported by browsers:

Result

Description

Entity Name

Number Code

Œ

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