HTML escape character table_html/css_WEB-ITnose
为什么要用转义字符串?
HTML中<,>,&等有特殊含义(<,>,用于链接签,&用于转义),不能直接使用。这些符号是不显示在我们最终看到的网页里的,那如果我们希望在网页中显示这些符号,该怎么办呢?
这就要说到HTML转义字符串(Escape Sequence)了。
转义字符串(Escape Sequence)也称字符实体(Character Entity)。在HTML中,定义转义字符串的原因有两个:第一个原因是像“<”和“>”这类符号已经用来表示HTML标签,因此就不能直接当作文本中的符号来使用。为了在HTML文档中使用这些符号,就需要定义它的转义字符串。当解释程序遇到这类字符串时就把它解释为真实的字符。在输入转义字符串时,要严格遵守字母大小写的规则。第二个原因是,有些字符在ASCII字符集中没有定义,因此需要使用转义字符串来表示。
转义字符串(Escape Sequence),即字符实体(Character Entity)分成三部分:
第一部分是一个&符号,英文叫ampersand;
第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;
第三部分是一个分号。
比如,要显示小于号(<),就可以写 < 或者 < 。
用实体(Entity)名字的好处是比较好理解,一看lt,大概就猜出是less than的意思,但是其劣势在于并不是所有的浏览器都支持最新的Entity名字。而实体(Entity)编号,各种浏览器都能处理。
提示:实体名称(Entity)是区分大小写的。
备注:同一个符号,可以用“实体名称”和“实体编号”两种方式引用,“实体名称”的优势在于便于记忆,但不能保证所有的浏览器都能顺利识别它,而“实体编号”则没有这种担忧,但它实在不方便记忆。
通常情况下,HTML会自动截去多余的空格。不管你加多少空格,都被看做一个空格。比如你在两个字之间加了10个空格,HTML会截去9个空格,只保留一个。为了在网页中增加空格,你可以使用 表示空格。
最常用的字符实体:
半方大的空白 | ||||||||
全方大的空白 | ||||||||
不断行的空白格 | ||||||||
< | 小于 | < | < | |||||
> | 大于 | > | > | |||||
& | &符号 | & | & | |||||
" | 双引号 | " | " | |||||
© | 版权 | © | © | |||||
® | 已注册商标 | ® | ® | |||||
? | 商标(美国) | ? | ™ | |||||
× | 乘号 | × | × | |||||
÷ | 除号 | ÷ | ÷ |
" | " | " |
& | & | & |
< | < | < |
> | > | > |
不断开空格(non-breaking space) |
? | ¡ | ¡ | Á | Á | Á | á | á | á |
¢ | ¢ | ¢ | Â | Â | ˆ | â | â | â |
£ | £ | £ | Ã | Ã | Ã | ã | ã | ã |
¤ | ¤ | ¤ | Ä | Ä | Ä | ä | ä | ä |
¥ | ¥ | ¥ | Å | Å | ˚ | å | å | å |
| | ¦ æ ; | æ | § | § | § | Ç | Ç | |
ç | ç | ç | ¨ | ¨ | ¨ | È | È | |
è | è | è | © | © | © | É | É | |
é | é | é | a | ª | ª | Ê | Ê | |
ê | ê | ê | ? | « | « | Ë | Ë | |
ë | ë | ë | ? | ¬ | ¬ | Ì | Ì | |
ì | ì | ì | /x7f | | | Í | Í | |
í | í | í | ® | ® î | ® | î | ||
ˉ | ¯ | ¯ | Ï | Ï | Ï | ï | ï | ï |
° | ° | ° | Ð | Ð | Ð | ð | ð | &ieth; |
± | ± | ± ñ ; | 2 | ² | ² | Ò | Ò | |
ò | ò | ò | 3 | ³ | ³ | Ó | Ó | |
ó | ó | ó | ′ | ´ | ´ | Ô | Ô | |
ô | ô | ô | μ | µ | µ | Õ | Õ | |
õ | õ | õ | ||||||
? | ¶ | ¶ | Ö | Ö | Ö | ö | ö | ö |
· | · | · | × | × | × | ÷ | ÷ | ÷ |
? | ¸ | ¸ | Ø | Ø | Ø | ø | ø | ø |
1 | ¹ | ¹ | Ù | Ù | Ù | ù | ù | ù |
o | º | º | Ú | Ú | Ú | ú | ú | ú |
? | » | » | Û | Û | Û | û | û | û |
? | ¼ | ¼ | Ü | Ü | Ü | ü | ü | ü |
? | ½ | ½ | Ý | Ý | Ý | ý | ý | ý |
? | ¾ | ¾ | Þ | Þ | Þ | þ | þ | þ |
? | ¿ | ¿ | ß | ß | ß | ÿ | ÿ | ÿ |
À | À | À | à | à | à |
\b | 退格 |
\f | 走纸换页 |
\n | 换行 |
\r | 回车 |
\t | 横向跳格 (Ctrl-I) |
\' | 单引号 |
\" | 双引号 |
\\ | 反斜杠 |
编程的时候要注意特殊字符的问题,很多运行时出现的问题都是因为特殊字符的出现而引起的。
注意,由于反斜杠本身用作转义符,因此不能直接在脚本中键入一个反斜杠。如果要产生一个反斜杠,必须一起键入两个反斜杠 (\\)。
参考资料:
http://114.xixik.com/character/

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.
