146 words
1 minutes
Writing Comments in HTML

Writing Comments in HTML#

Comments in HTML are used to leave notes or explanations within the code that are not displayed in the browser. This guide explains how to write comments in HTML.

Basic Syntax#

To write a comment in HTML, use the following syntax:

<!-- This is a comment -->

Multi-line Comments#

You can also write multi-line comments by placing the comment tags around multiple lines of text:

<!-- 
This is a multi-line comment.
It spans multiple lines.
-->

Use Cases#

Documenting Code#

Comments can be used to document the purpose of specific sections of code:

<!-- Navigation bar -->
<nav>
  <!-- ... -->
</nav>

Temporarily Disabling Code#

You can use comments to temporarily disable sections of code without deleting them:

<!-- <div class="temporary-disabled">
  <p>This section is disabled.</p>
</div> -->

Conclusion#

Writing comments in HTML is a simple yet powerful way to document and manage your code. By using comments effectively, you can make your HTML code more readable and maintainable.


Writing Comments in HTML
https://zxce3.net/posts/writing-comments-in-html/
Author
Memet Zx
Published at
2021-09-12