HTML (4) annotation and HTML Encoding

Source: Internet
Author: User
Tags html comment

I. html comment:

In the HTML document, the annotation is expressed as: <! -- HTML comment -->, where "HTML comment" is the content of the comment. When the browser parses the HTML document, the commented content will be ignored, it is not displayed when the user browses the web page.

1. Main purposes of HTML Annotations:

A. It is used to describe the functions of some parts of the HTML document.

1 <! -- The following is the title of an HTML document --> 2 <title> HTML encoding and comment </title>

B. for web page debugging, for example, you can comment out a tag or a document during website development, and then refresh the page to view the effect. If you need to directly remove the comment, you can, you don't have to spend time writing code again. This is a common method in web design.

1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <HTML xmlns = "http://www.w3.org/1999/xhtml"> 3 

2. NOTE: Annotations cannot be nested. The reason is the first "<! -- "Matches the first" --> "that appears after it as the end of the comment. This leads to "-->" in the outer layer of the nested comment cannot find the matching start tag. Is an example of an error caused by annotation nesting. In vs2010, it will prompt you for an error.

  

Ii. html encoding-symbols and special characters in HTML documents

When you want to display special characters such as HTML tags (such as "<" and ">") and space characters that are ignored by the browser, if you type these characters in the HTML code of a webpage, the desired effect will not be reached. This is what I was confused when I first came into contact with HTML and webpage design. The reason is: when the browser encounters such strings, it will parse them as tags or ignore them (spaces ), therefore, some special methods are required to represent these characters in the HTML source file, for example, "& lt;" indicates "<". The special characters are encoded in HTML format. In addition, some characters that cannot be entered through the keyboard must also be encoded in HTML, for example, "& #169;" or "& copy;" to represent the copyright symbol ().

For example, to display "Hello <welcome> China" on an HTML webpage, it must be expressed by "Hello & lt; Welcome & gt; China", where "& lt;" indicates "<", "& gt;" indicates "> ".

HTML encoding format: lhtml encoding starts with "&" and ends. Below are some common HTML encoding lists.

  

For more HTML code, visit http://www.htmlhelp.com/reference/charset.

  

 

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.