0% found this document useful (0 votes)
2 views

HTML Comments

HTML comments are used to document source code and are not displayed in the browser. They can also be used to hide content temporarily and assist in debugging by allowing developers to comment out code. The correct syntax for an HTML comment is <!-- comment here -->.

Uploaded by

Asif Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

HTML Comments

HTML comments are used to document source code and are not displayed in the browser. They can also be used to hide content temporarily and assist in debugging by allowing developers to comment out code. The correct syntax for an HTML comment is <!-- comment here -->.

Uploaded by

Asif Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++

HTML Comments
❮ Previous Next ❯

HTML comments are not displayed in the browser, but they can help document your HTML
source code.

HTML Comment Tag


You can add comments to your HTML source by using the following syntax:

<!-- Write your comments here -->

Notice that there is an exclamation point (!) in the start tag, but not in the end tag.

Note: Comments are not displayed by the browser, but they can help document your HTML
source code.

Add Comments
With comments you can place notifications and reminders in your HTML code:

Example
<!-- This is a comment -->
Tutorials  Exercises  Services   Sign Up Log in

<p>This is a paragraph.</p>
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++

<!-- Remember to add more information here -->

Try it Yourself »

Hide Content
Comments can be used to hide content.

This can be helpful if you hide content temporarily:

Example
<p>This is a paragraph.</p>

<!-- <p>This is another paragraph </p> -->

<p>This is a paragraph too.</p>

Try it Yourself »

You can also hide more than one line. Everything between the <!-- and the --> will be hidden
from the display.

Example
Hide a section of HTML code:

<p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->
<p>This is a paragraph too.</p>
Try it Yourself »
Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++
Comments are also great for debugging HTML, because you can comment out HTML lines of
code, one at a time, to search for errors.

Hide Inline Content


Comments can be used to hide parts in the middle of the HTML code.

Example
Hide a part of a paragraph:

<p>This <!-- great text --> is a paragraph.</p>

Try it Yourself »

?
Exercise
What is the correct syntax for adding a comment in HTML?

<-- This is a comment -->

<## This is a comment ##>

<--> This is a comment </-->

<!-- This is a comment -->

Submit Answer »
 Tutorials  Video:
Exercises  HTML
Services  Comments
 Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++

❮ Previous Next ❯

Track your progress - it's free! Sign Up Log in


 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++

COLOR PICKER



 PLUS SPACES

GET CERTIFIED FOR TEACHERS

FOR BUSINESS CONTACT US

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial

 SQL Tutorial
Tutorials  Python
Exercises
Tutorial
W3.CSS Tutorial
 Services   Sign Up Log in

HTML
 CSS Bootstrap Tutorial
JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

    

FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie
and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

You might also like