Comments in HTML
In HTML, Comments are used to add notes, explanations, or reminders within the code. The comments are ignored by web browsers and do not appear on the web page. Comments are helpful for documenting your code, making it easier to understand for yourself and others.
Syntax
To write a comment in HTML, we enclose our HTML code within '<!--' and '-->'.
Example :
Output :
Uses of Comments
* Explain code : It is used to describe the purpose of specific parts of the HTML.
* Leave reminders: It is used to add TODOs or notes for future updates.
* Temporarily disable code: It is used to comment out code you don’t want to run or display.
* Improve collaboration: It is used to help others to understand your code when working in teams.
Best Practices
* Write comments clear and concise.
* Do not overuse comments, we only add them where necessary.
* Avoid putting sensitive information in comments, as the source code can be viewed by anyone.
Example:
Note :
Comments are for developers and do not affect how the web page looks or works.
Comments
Post a Comment