HTML slt;!--...-- and comment labels
Label definition and instructions for use
The comment !--...-- is used to insert comments into the source document. Comments do not appear in the browser.
You can use comments to interpret your code, which will help you edit your code at a later time. Especially in situations where the amount of code is large is useful.
You can also store information tailored to the program in the comment content. I n this case, this information is not visible to the user, but is available to the program. It is a good practice to put comments or style elements into the comment text so that older browsers that do not support scripts or styles do not display them as plain text.
<script type="text/javascript">
<!--
function displayMsg()
{
alert("Hello World!")
}
//-->
</script>
Note: The last two forward slashes (/) on the command line are JavaScript comment symbols. This ensures that JavaScript does not execute the --gt; tag.
In addition to playing a significant role in source documents, many Web servers also use annotations to implement features specific to document server-side software. T hese servers can scan documents, find specific sequences of characters from traditional HTML/XHTML comments, and then act according to the commands embedded in the comments. These actions can be simply including text in other files (so-called server-side inclusion, server-inside), or they can be the complex execution of other commands to dynamically generate the contents of a document.
HTML comments:
<p>这是一个段落</p>
Try it out . . .
Browser support
All major browsers support the !--...-- and comment tags.
The difference between HTML 4.01 and HTML5
No.
The standard property
The comment !--...-- does not support any standard properties.
For more information about HTML standard properties, visit Standard Properties.
The event property
The comment !--...-- does not support any event properties.
For more information about HTML event properties, visit Event Properties.
The role of HTML comments
Code example
<!--
这是w3cschool网站首页头图
-->
<img src="http://statics.w3cschool.cn/images/w3c/intro.png" alt="w3cschool" />
Results:
Analytical:
1, from the above example we can see that the text of the comment section is missing after running, but if you look at the source code you can see the content of this part.
2, in the example also appeared in the "picture path" alt , "picture name" /<!--
这是w3cschool网站首页头图
-->
The src property of the label is required.
Its value is the URL of the image file, which is the absolute or relative path of the file that references the image.
How to view comments:
1, first of all, on the web page to click the right mouse button, choose to view the source code.
2, after entering the source code page, press ctrl-f will appear search box
3, enter the "!--" you can find the comment label! I n addition to being used for illustration, comment labels are often used to comment out code that is not needed to be displayed for the time being. F or example, if you do an event and you don't open the page until 10 a.m. tomorrow, you can write and upload the code in advance, and then delete the comments at the beginning of the event to make changes to the site more quickly.
Of course, the result of this search is to show all the comment labels, if the code owner himself wants to find a comment label, in the search box directly enter the comment label text content.
I've heard that many programmers like to write funny comment tags, such as:
<!--
下面这串代码是经理要求加的,目的就是为了拖慢网页加载速度,好再坑客户一笔优化网站的钱
-->
<link rel="stylesheet" href="//www.w3cschool.cn/foo.css" type="text/css">
<!--
这个页面的代码都不要动!不要动!不要动!我动了之后就后悔了
-->
......
<!--
这段代码好像是没用的,但是我不敢删掉
-->
......
Above is the html comment label, the comment label and another form of expression, used in the C language.
/*这里是注释标签*/
//这里是注释标签