HTML comments are placed in between <!-- ... --> tags. So, any content placed with-in <!-- ... --> tags will be treated as comment and will be completely ignored by the browser.
Single-line comments in HTML
Example
Let us see an example of single-line comments in HTML −
<!DOCTYPE html> <html> <head> <!-- Document Header Starts --> <title>This is document title</title> </head> <!-- Document Header Ends --> <body> <p>Document content goes here.....</p> </body> </html>
Output
This will produce the following output. The text in the comments never gets printed −
Multi-line comments in HTML
Example
We can also set multi-line comments in HTML. Let us see an example −
<!DOCTYPE html> <html> <head> <!-- Document Header Starts --> <title>This is document title</title> </head> <!-- Document Header Ends --> <body> <h2>Heading Two</h2> <!-- This is a multiline comment and it can span through as many as lines you like. --> <p>Document content goes here.....</p> <p>We have set comments in the document as well, but it won't get displayed.</p> </body> </html>
Output
This will produce the following output. The text in the multi-line comment won’t get displayed −