Course Content
HTML Introduction
0/1
HTML Editors
0/1
HTML Basic Tags
0/1
HTML Elements
0/1
HTML Attributes
0/1
HTML Headings
0/1
HTML Paragraph
0/1
HTML Text Formatting
0/1
HTML Meta Tags
0/1
HTML Quotations
0/1
HTML Comments
0/1
HTML Images
0/1
HTML Background
0/1
HTML Colors
0/1
HTML Lists
0/1
HTML Tables
0/1
HTML Forms
0/1
HTML Spell Check
0/1
HTML Media
0/1
HTML Marquees
0/1
HTML CSS
0/1
HTML Links
0/1
HTML Block & Inline
0/1
HTML Classes
0/1
HTML Id
0/1
HTML I frames
0/1
HTML Java script
0/1
HTML File paths
0/1
HTML Layout
0/1
HTML Responsive
0/1
HTML Computer Code
0/1
HTML Tutorial
About Lesson

HTML Comment Tag

In this tutorial, we will learn about comment tag in HTML with the help of examples.


Comment Tag

HTML comment tag is used to insert comments in the HTML documents.
Comments are a piece of code that is ignored by the browser, but they can help document your HTML source code.

It is a good practice to add comments into your HTML code, especially in long and complex documents, to indicate sections of documents.

 

  • You can add one or more comments to your HTML document.
  • Comments are represented by <!–– ––>.
  • It is a good practice of coding to add comments to your HTML source code.
  • Comments help the coder and other people to understand the Source code of the document.
  • The comment tag is useful during the debugging of codes.
  • Browsers automatically ignore comments, but they can help document your HTML source code.

Types of Comment

There are two types of comments in HTML

  1. Single-line Comment
  2. Multi-line Comment

Single-line Comment

Single-line Comments are use to comment in one line only.

Syntax

<!--This is the syntax of Single-line comment-->

Example

<!DOCTYPE html>
<html>
  <head>
    <title>HTML comments</title>
  </head>
  <body>
    <!--This is a comment-->
    <p>This is a simple text</p>
  </body>
</html>

Output

<!--This is a comment-->

This is a simple text


Multi-line Comment

Multi-line Comments are use to comment in more that one line.

Syntax

<!--This is the 
    syntax of
    Multi-line comment-->

Example

<!DOCTYPE html>
<html>
  <head>
    <title>HTML comments</title>
  </head>
  <body>
    <!--This is a comment
    <p>This is a first paragraph</p>-->

    <p>This is a second paragraph.</p>
  </body>
</html>

Output

<!--This is a comment

This is a first paragraph

-->

This is a second paragraph.

error: Content is protected !!