Home >Web Front-end >HTML Tutorial >HTML Deep-Level Function Analysis of Comment Tags_HTML/Xhtml_Web Page Production
Deep-Level Function Analysis of Comment Tags_HTML/Xhtml_Web Page Production -->When we look at the source code of many websites, we will find a lot of comments. Especially the Sina comment tag is used to insert comments in the source document. The comment text is generally used as a reference for programmers, especially for large-scale, multi-person developed websites. Source code, if there are no comments, the code written by programmer A cannot be recognized by programmer B. In this way, if programmer A leaves his job, the code written by him will be difficult to maintain. With comments, it will be easier to understand the code.
Sina source code HTML comments (green text is the comment)
HTML comments are ignored by browsers, and HTML comments are written directly inside the website source code and will not be displayed on the front end. As shown in the picture above, the green parts are comments and will not be displayed. Through the green text above, we can know what this code means and the beginning and end of the code. The HTML comment format is as follows:
HTML comments advanced functions
As the name suggests, HTML comments are comments, internal comments on the program. In fact, this is only the most basic function, but it is precisely because of these functions that are ignored by front-end browsers that modern web programs have conducted a deeper exploration of annotations, making annotations more and more useful.
The role of CSS/JS in the page
HTML comments are also used for in-page Javascript and CSS code. Many old browsers or browsers that cannot recognize Javascript and CSS will often display text if they write code directly, which greatly affects reading.
Jbzj!
The above code does not use HTML comments. If accessed in some old mobile browsers and versions below IE6, the following text will be displayed:
Jbzj!
Even if these old browsers do not recognize tags such as
HTML comments are used in MVC design
Many modern open source code projects, especially MVC web design style open source code, these projects will insert some comments into the traditional HTML code, and then add content such as advertisements to these comments.
Discuz uses HTML comments to insert code and determine Discuz code