HTML – Comments
In HTML, comments are used to add notes or explanations within the code that are not displayed on the web page. They are helpful for developers to provide additional information or to temporarily disable specific parts of the code without deleting them.
To create a comment in HTML, you can use the following syntax:
<!-- This is a comment -->
Comments in HTML start with
<!-- and end with
-->. Everything between these delimiters is treated as a comment and is ignored by the web browser when rendering the page.
Here’s an example of how comments can be used in an HTML document:
<title>My Web Page</title>
<!-- This is the header section -->
<h1>Welcome to my website!</h1>
<!-- <p>This paragraph is temporarily disabled</p> -->
<!-- This is the main content section -->
<p>Here is some information about myself...</p>
<!-- This is the footer section -->
<p>© 2023 My Web Page. All rights reserved.</p>
In the above example, you can see how comments are used to provide descriptions for different sections of the HTML document and to temporarily disable a paragraph within the header.
Remember that comments are not visible on the rendered web page and are only meant for developers to read and understand the code.