HTML comments are enclosed within <!–
and –>
, and serve to annotate code for developers. They provide explanations, reminders, or instructions that are invisible on the rendered webpage. These comments aid collaboration and enhance code readability.
Comment | Descriptions | Syntax |
---|---|---|
Single-line | The single-line comment is given inside the ( <!– comment –> ) tag. | <!– comment –> |
Multi-line | It follows the syntax of a single-line comment by adding multiple lines in the comment. | <!– Multi |
<!DOCTYPE html> <html> <head> <title>Online HTML Editor</title> </head> <body> <!-- This is a single Comment--> <h1>INterntpoint</h1> <!-- This is a single line Commnet --> <p>Simply Easy Learning</p> </body> </html>
Conditional Comments
Conditional comments are a feature specific to Internet Explorer (IE) on Windows but they are ignored by other browsers. They are supported from Explorer 5 onwards.
<html> <head> <title>Conditional Comments</title> <!--[if IE 6]> Special instructions for IE 6 here <![endif]--> </head> <body> <p>Document content goes here.....</p> </body> </html>
Comments are also great for debugging HTML, because you can comment out HTML lines of code