HTML Code Comments
What are HTML Comments?
Imagine writing sticky notes on the back of a canvas painting. The visitors in the gallery can't see the sticky notes, but other artists or curators can read them to understand how the painting was set up. In HTML, Comments are notes written in the code that are completely ignored by the browser when rendering the page.Why does it matter?
As your code grows, it becomes harder to keep track of what different sections do. Comments help you:How to write it
An HTML comment starts with<!-- and ends with -->. Anything you put between these two markers will be invisible on the live website.Here is the comment syntax:
<!-- This is a comment and won't show up on the website -->
<p>This paragraph is visible to visitors!</p>
<!-- Comment is invisible -->
<p>Paragraph is visible</p>
Common Mistakes
<!-- but forget the closing -->, the browser will think the rest of your entire webpage is a comment and hide everything!<!-- text <!-- nested --> text -->). This will break the rendering.Quick Reference
<!-- comment text --> โ Invisible developer note.Your Task
Create a comment containing the text 'This is a test comment' below the paragraph.
index.html
Type code above to start the lesson.
Live Preview