HTML Escape string (Escape Sequence)

Source: Internet
Author: User

Why should I use an escape string?

<,>,& in HTML has special meanings (<,>, used for link-sign,& for escaping) and cannot be used directly. These symbols are not displayed in the pages we end up seeing, so what if we want to display the symbols in the Web page?

This is about the HTML escape string (Escape Sequence).

The Escape string (Escape Sequence) is also called the character entity (Character entity). In HTML, there are two reasons for defining an escaped string: The first reason is that symbols such as "<" and ">" are already used to represent HTML tags, so they cannot be used directly as symbols in text. In order to use these symbols in an HTML document, you need to define its escape string. When the interpreter encounters such a string, it interprets it as a real character. When you enter an escaped string, you strictly follow the rules for letter-case. The second reason is that some characters are not defined in the ASCII character set, so you need to use an escape string to represent them.

The composition of the escaped string

The Escape string (Escape Sequence), the character entity (Character entity), is divided into three parts: the first part is a & symbol, English is called Ampersand; the second part is the entity name or the # Add the entity number, and the third part is a semicolon.

For example, to display a less than sign (<), you can write &lt; or & #60;.

The advantage of the entity name is better understanding, a look at LT, probably guess is less than meaning, but its disadvantage is that not all browsers support the latest Entity name. The entity number can be processed by various browsers.

Tip: Entity names (entities) are case-sensitive.

Note: The same symbol can be referenced in both "Entity name" and "entity number", "Entity name" advantage is easy to remember, but does not guarantee that all browsers will be able to identify it, and "entity number" There is no such worry, but it is not easy to remember.

How do i show spaces?

In general, HTML automatically truncates extra spaces. No matter how many spaces you add, it's considered a space. For example, if you add 10 spaces between two characters, the HTML will truncate 9 spaces, leaving only one. To add spaces to the page, you can use &nbsp; to represent spaces.

HTML Escape string (Escape Sequence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.