html escape tag

WBOY
Release: 2023-05-21 15:54:08
Original
581 people have browsed it

HTML escape tag is a special tag that can be used to escape special characters in HTML code into ordinary text characters to prevent these special characters from being interpreted as HTML code by the browser. When writing HTML code, you often need to use some special characters, such as the less than sign, the greater than sign, quotation marks, & signs, etc. If they are not escaped into ordinary text characters, it will cause HTML format errors and affect the normal display of the page. This article will introduce the use of HTML escape tags and common escape characters.

The format of the HTML escape tag is "&" "escape character name" ";", where the escape character name is the entity name or entity number of the character in HTML. The following lists some commonly used HTML escape characters:

  1. < Less than sign
  2. > Greater than sign
  3. " Quotation marks
  4. & &
  5. ' single quote

The method of using HTML escape tags is very simple. You only need to add an escape tag before the characters that need to be escaped. For example, if you want to To write a sentence in HTML: Today is a day!, you should use the following code:

Today is a &lt;good&gt; day!
Copy after login

The effect displayed in the browser is: Today is a day!.

It should be noted that some special characters do not have corresponding entity names or entity numbers in HTML. In this case, Unicode encoding needs to be used instead of escape tags. For example, if you want to use the copyright symbol "©" in HTML , the following Unicode encoding should be used:

©
Copy after login

The effect displayed in the browser is: "©".

In addition to the common HTML escape characters mentioned above, there are also some very practical escape characters Definition tag.

  1. : Space
    In HTML, sometimes multiple consecutive spaces need to be used to format text, but multiple consecutive spaces will be parsed into one space by the browser. At this time, You can use to replace spaces.
  2. ©: Copyright symbol (Copyright)
    In HTML, it is often necessary to add copyright information at the bottom of the document. In this case, you can use © to represent the copyright symbol.
  3. ®: Registered trademark symbol (Registered)
    In HTML, it is often necessary to add the ® symbol after the trademark name to indicate that the trademark has been registered. In this case, you can use ® to represent the registered trademark symbol.
  4. ×: Multiplication sign (Multiplication)
    In HTML, sometimes it is necessary to use the multiplication sign to express the multiplication relationship of numbers. In this case, you can use × instead of the multiplication sign.
  5. ÷: Division sign ( Division)
    In HTML, sometimes you need to use the division sign to express the division relationship of numbers. In this case, you can use ÷ instead of the division sign.

In short, HTML escape tags are used when writing HTML It is very practical when coding. It can avoid some common mistakes and also make the code more beautiful. I hope this article can help everyone better master the use of HTML escape tags.

The above is the detailed content of html escape tag. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!