Comments in HTML
Syntax
The start of a comment in HTML is indicated by <!--
. Everything following this up to the closing -->
is considered a comment and will not be rendered by a browser.
1 2 3 4 5 6 7 | <html> <head> <!-- This is only comment and will not be displayed. --> <!-- Show welcome message in title --> <title> Welcome to programming-guides.com!</title> </head> </html> |
Adding comments in HTML is a good practice just like in other programming languages. Comments can be used to identify what various pieces of the HTML source are (e.g. <!-- menu -->
, `, etc.) so that the reader does not have to spend time reading the whole source in order to figure it out.
Comments can also be used in development to quickly disable a large chunk of code in what’s referred to as “commenting out” code.