¡¾·±ÌåÖÐÎÄ¡¿
¡¾ÉèΪÊ×Ò³¡¿
¡¾¼ÓÈëÊղء¿
µ±Ç°Î»ÖãºÍøÕ¾ÖÆ×÷Ê×Ò³ >> HTML½Ì³Ì >> HTML ʵÌå×Ö·û

HTML ʵÌå×Ö·û

2007-07-15 08:00:00  ×÷Õߣº  À´Ô´£º»¥ÁªÍø  ä¯ÀÀ´ÎÊý£º0  ÎÄ×Ö´óС£º¡¾´ó¡¿¡¾ÖС¿¡¾Ð¡¡¿
¼ò½é£ºSome characters like the < character, have a special meaning in HTML, and therefore cannot be used in the text. ÓÐЩ×Ö·û£¬Ïñ
¹Ø¼ü×Ö£ºÊµÌå ×Ö·û HTML

Some characters like the < character, have a special meaning in HTML, and therefore cannot be used in the text.

ÓÐЩ×Ö·û£¬Ïñ<ÕâÀàµÄ£¬¶ÔHTMLÀ´ËµÊÇÓÐÌØÊâÒâÒåµÄ£¬ËùÒÔÕâЩ×Ö·ûÊDz»ÔÊÐíÔÚÎı¾ÖÐʹÓõġ£

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: < 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ä¯ÀÀÆ÷£©

Non-breaking Space

²»»»Ðмä¸ô

The most common character entity in HTML is the non-breaking space.

ÔÚHTMLÖÐ×îÆÕͨµÄʵÌå×Ö·û¾ÍÊDz»»»Ðмä¸ôÁË¡£

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¸ö¡£ÏëÌí¼Ó¼ä¸ôµÄ»°¾ÍµÃʹÓà ×Ö·û¡£

The Most Common Character Entities:

һЩºÜ³£ÓõÄʵÌå×Ö·û:

Result

½á¹û

Description

ÃèÊö

Entity Name

ʵÌåÃû

Entity Number

ʵÌåÊý

non-breaking space

·Ç»»Ðмä¸ô

<

less than

СÓÚ

<

<

>

greater than

´óÓÚ

>

>

&

ampersand

¡°&¡± ºÅ

&

&

"

quotation mark

Ë«ÒýºÅ

"

"

'

apostrophe

µ¥ÒýºÅ

' (does not work in IE)

IE²»Ö§³Ö

'

Some Other Commonly Used Character Entities:

ÆäËü³£ÓÃ×Ö·ûʵÌå:

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.

²é¿´ÍêÕûµÄʵÌå×Ö·û

ÔðÈα༭£ºadmin
±¾ÎÄÒýÓõØÖ·£º http://www.3pcode.com/web/2007/07/90594.htm
Ïà¹ØÎÄÕÂ