HTML Comments


HTML comments are very important for developers, providing a way to annotate code without affecting the rendered webpage. HTML comments enhance code readability, facilitate collaboration, and can be used to temporarily disable code segments.

The <!-- --> syntax is used in HTML documents or .html files to enclose HTML elements. It can be used for both single-line and multi-line comments, helping HTML authors annotate or disable HTML elements.It can also be used to hide part or all of an element’s content — this is called an inline comment.

Single-Line Comment

Example

Run Code
<html>
<head>
    <title>Single-Line Comment</title>
</head>
<body>
    <!-- This is single line comment -->
    <!-- <h2>Hello World</h2> -->
</body>
</html>

Inline Comment

Multiple-Line Comment