Introduction to HTML Annotation

Almost most web programming languages have the function of annotations. HTML annotations start with <!-- and end with -->. The content in between will be regarded as annotations by the browser and displayed on the web page It will be ignored when you check the source code. HTML annotations are used for maintenance by web designers.


Standard HTML annotation writing

<!-- ... Here is the comment text ... -->


The text in the comment block will not be displayed on the web page, even if the HTML code is written in the block, it will not be executed! The browser will judge by itself. Almost all mainstream browsers can judge normally. In addition to single-line annotations, such annotations can also contain multiple-line annotations at once.

Simple example of HTML annotation

The single quotation mark on the right is the comment content "<!--Here is the comment text-->"


The result is

The single quotation mark on the right is the content of the comment ""


Simple example of HTML multi-line comments
<!--
Here is multi-line HTML annotation text
Here is multi-line HTML annotation text
-->
No matter it is a single line or multiple lines, as long as the text between the comment symbols <!-- and --> will not be displayed on the web page. HTML annotations are quite simple and easy to use, but water can carry a boat and it can overturn the boat. It is often seen that there are a lot of HTML annotations in the source code of some websites, which makes the code very verbose. This is definitely not a good phenomenon. The purpose of is to mark some key points for future code maintenance and use, not to delete an element in a web page. Since the web page element is to be deleted, it should be cleared directly instead of hiding it with comments.

Differences between HTML annotations and CSS syntax

With the evolution of CSS technology, it has become commonplace to add CSS syntax to web pages, but the beginning and end of CSS syntax will be marked with similar HTML annotations. How does the browser judge it? A CSS syntax combined with an HTML page may be similar to the following, usually placed between the <head></head> tags.
<style type="text/css">
<!--
...Here is CSS Code...
-->
</style>
This CSS grammar is also embedded in the HTML page, but because of the tags of <style type="text/css"> and </style>, the browser will judge the code inside as CSS Code, so those two seem The HTML annotation symbols are not affected, and the CSS Code in the meantime is still effective.

Post a Comment

0 Comments