HTML Comment<!-- Comments --> Tag
Tags: learnhtml
Published: 2021-02-08 10:30:09

---
title: HTML Comment<!-- Comments --> Tag
published: true
date: 2021-02-05 12:21:14 UTC
tags: LearnHTML
canonical_url: https://sharepointanchor.com/learn-html/html-comments-tag/
---

In <abbr title="HyperText Markup Language">HTML</abbr> the **comment tag** is used to **insert the comments** in the source code. These comments are **not displayed in the browser**. You can use the comments to **explain your code** , which can help you when you edit the source code.

The comments will point out the document sections or insert notes explaining the code. You can use the comment tag anywhere in the documents except the **<title>** tag.

## Syntax:

The comment tag begins with an **open angular bracket `(<)`**, **exclamation symbol `(!)`** followed by a **double dash sequence `(--)`**. After that, you may type your content. Finally, close the tag with a **double dash sequence `(--)`** and **close an angular bracket `(>)`**.

Comments are written between **` <!-- Comments -->`** symbols.

**Note:** The exclamation point (!) is used only in the start tag, you don’t need to put it in the end tag.

## Sample of the HTML Comment tag:

```

<!DOCTYPE html>
<html>
  <head>
    <title>Title of HTML Comment Tag</title>
  </head>
  <body>
    <p>The content of the document</p>
    <!-- This is our comment, that is not displayed on the browser--> 
  </body>
</html>

```

## Result:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/Result-2.png)<figcaption>Result</figcaption>

From the result, the comment tag will **“hide”** the script from the browser, so it doesn’t appear.

Inside the comment tag, you can type any language you need. You can also write [JavaScript](https://sharepointanchor.com/category/learn-javascript/)and [CSS](https://sharepointanchor.com/category/learn-css/) codes as a comment. What the thing will have appeared between the comment tag, the browser just ignores this text. Refer to the below JavaScript code.

```

<!DOCTYPE html>
<html>
   <head>
      <title>Title of HTML Comment Tag</title>      
      <script>
         <!-- 
            document.write("Hello World!")
         //-->
      </script>
   </head>	
   <body>
<p>The content of the document</p>
        </body>	
</html>

```

In **JavaScript** , you need to type **two forward slashes** before the **end command tag**. This will stop the JavaScript from running between the comment tag.

Similarly, you can use the comment tag to hide the [CSS](https://sharepointanchor.com/category/learn-css/)code from the browser.

```

<!DOCTYPE html>
<html>
  <head>
    <title>Title of HTML Comment Tag</title>
  </head>
  <body>
    <p>The content of the document</p>
<style>
<!--
      a {color: #1c87c9;}
-->
    </style>
    <!-- This is our comment, that is not displayed on the browser--> 
  </body>
</html>

```

## Browser Support:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/Browser-Support-1.png)<figcaption>Browser Supports</figcaption>

The post [HTML <code><!-- Comments --></code> Tag](https://sharepointanchor.com/learn-html/html-comments-tag/) appeared first on [Share Point Anchor](https://sharepointanchor.com).