为什么要用转义字符串?
HTML中,&等有特殊含义(,用于链接签,&用于转义),不能直接使用。这些符号是不显示在我们最终看到的网页里的,那如果我们希望在网页中显示这些符号,该怎么办呢?
这就要说到HTML转义字符串(Escape Sequence)了。
转义字符串(Escape Sequence)也称字符实体(Character Entity)。在HTML中,定义转义字符串的原因有两个:第一个原因是像“”这类符号已经用来表示HTML标签,因此就不能直接当作文本中的符号来使用。为了在HTML文档中使用这些符号,就需要定义它的转义字符串。当解释程序遇到这类字符串时就把它解释为真实的字符。在输入转义字符串时,要严格遵守字母大小写的规则。第二个原因是,有些字符在ASCII字符集中没有定义,因此需要使用转义字符串来表示。
转义字符串(Escape Sequence),即字符实体(Character Entity)分成三部分:
第一部分是一个&符号,英文叫ampersand;
第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;
第三部分是一个分号。
比如,要显示小于号(
" | " | " |
& | & | & |
< | < | |
> | > | > |
不断开空格(non-breaking space) |
? | ¡ | ¡ | Á | Á | Á | á | á | á |
¢ | ¢ | ¢ | Â | Â | ˆ | â | â | â |
£ | £ | £ | Ã | Ã | Ã | ã | ã | ã |
¤ | ¤ | ¤ | Ä | Ä | Ä | ä | ä | ä |
¥ | ¥ | ¥ | Å | Å | ˚ | å | å | å |
| | ¦ æ ; | æ | § | § | § | Ç | Ç | |
ç | ç | ç | ¨ | ¨ | ¨ | È | È | |
è | è | è | © | © | © | É | É | |
é | é | é | a | ª | ª | Ê | Ê | |
ê | ê | ê | ? | « | « | Ë | Ë | |
ë | ë | ë | ? | ¬ | ¬ | Ì | Ì | |
ì | ì | ì | /x7f | | | Í | Í | |
í | í | í | ® | ® î | ® | î | ||
ˉ | ¯ | ¯ | Ï | Ï | Ï | ï | ï | ï |
° | ° | ° | Ð | Ð | Ð | ð | ð | &ieth; |
± | ± | ± ñ ; | 2 | ² | ² | Ò | Ò | |
ò | ò | ò | 3 | ³ | ³ | Ó | Ó | |
ó | ó | ó | ′ | ´ | ´ | Ô | Ô | |
ô | ô | ô | μ | µ | µ | Õ | Õ | |
õ | õ | õ | ||||||
? | ¶ | ¶ | Ö | Ö | Ö | ö | ö | ö |
· | · | · | × | × | × | ÷ | ÷ | ÷ |
? | ¸ | ¸ | Ø | Ø | Ø | ø | ø | ø |
1 | ¹ | ¹ | Ù | Ù | Ù | ù | ù | ù |
o | º | º | Ú | Ú | Ú | ú | ú | ú |
? | » | » | Û | Û | Û | û | û | û |
? | ¼ | ¼ | Ü | Ü | Ü | ü | ü | ü |
? | ½ | ½ | Ý | Ý | Ý | ý | ý | ý |
? | ¾ | ¾ | Þ | Þ | Þ | þ | þ | þ |
? | ¿ | ¿ | ß | ß | ß | ÿ | ÿ | ÿ |
À | À | À | à | à | à |
\b | 退格 |
\f | 走纸换页 |
\n | 换行 |
\r | 回车 |
\t | 横向跳格 (Ctrl-I) |
\' | 单引号 |
\" | 双引号 |
\\ | 反斜杠 |
编程的时候要注意特殊字符的问题,很多运行时出现的问题都是因为特殊字符的出现而引起的。
注意,由于反斜杠本身用作转义符,因此不能直接在脚本中键入一个反斜杠。如果要产生一个反斜杠,必须一起键入两个反斜杠 (\\)。
参考资料:
http://114.xixik.com/character/

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

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 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

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

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


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
