<!-- ... -->

HTML <!– … –> tag

The <!– … –> tag is used to insert comments in an HTML code. Its content is ignored by the browsers and is not displayed by them. However, the comments are visible to anyone who views the page source code.

HTML comments point out document sections or insert notes explaining the code. The comment tag can also be used to exclude short-term code blocks instead of deleting them.

Comments can be used anywhere in the documents except for the <title> tag.

Syntax

Syntax

Comments are written between <!– and –> symbols.

Example of the HTML comment tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Example of using the comment tag.</title>
  </head>
  <body>
    The content of the page. 
    <!-- This is our comment, that is not displayed on the browser. --> 
  </body>
</html>

Result

The comment tag can be used for “hiding” scripts from browsers without any support for scripts.

<script type="text/javascript">
  <!--
  function displayMsg() {
    alert("Comment tag")
  }
  //-->
</script>

In the example above, the two forward slashes that are located at the end of the line (//) is the comment symbol of JavaScript . This stops JavaScript from running the –> tag.

The comment tag doesn’t support the Global Attributes.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部