Creating a Basic Comment Section on a Website with HTML, CSS, and JavaScript

To hide a section of HTML code, you can use comments. For instance, if you want to hide a paragraph and an image code, you can use comments to surround them. You can also use comments to debug HTML code. Commenting out HTML code lines one by one helps in searching for errors. Hence, comments are highly recommended to be used while writing HTML code.


Although HTML comments are not considered as
displayed in the browser
, they can still be utilized to document your HTML
source code
.


HTML Comment Tag

Here is the syntax you can use to add
add comments
to your HTML source.

The start tag contains an exclamation point (!), while the end tag does not.


It is important to note that although comments in HTML source code are not visible to the user on the browser, they serve as helpful documentation.


Add Comments

By making use of comments, you have the ability to add notifications and reminders to your HTML code.

Example

This is a paragraph.

Try it Yourself »


Hide Content

Comments can be used to hide content.

If you need to temporarily conceal content, it can be beneficial.

Example

This is a paragraph.

This is a paragraph too.

Try it Yourself »

To conceal multiple lines, simply include everything between

<!--

and

-->

and it will not be visible on the screen.

Example

Hide a section of HTML code:

This is a paragraph.

This is a paragraph too.

Try it Yourself »

HTML comments serve as an effective debugging tool, allowing you to search for errors by commenting out individual lines of code.



Hide Inline Content

Comments within the HTML code can be utilized to conceal certain sections.

Example

Hide a part of a paragaph:

This

is a paragraph.

Try it Yourself »


HTML Exercises

Frequently Asked Questions