HTML Comments
Comments in HTML are used to leave notes or explanations in the code. These are ignored by the browser and are not displayed on the webpage.
Why use comments?
- To explain sections of code
- To leave reminders or notes
- To temporarily disable code without deleting it
HTML Comment Syntax
You write a comment using this format:
<!-- This is a comment -->
Example
<h1>Welcome to my website</h1>
<!-- This heading introduces the site -->
<p>This is the homepage.</p>
<!-- Remember to add a contact form here later -->
Comments can also span multiple lines:
<!--
This is a multi-line comment.
It helps describe complex code or
organize sections.
-->