0% completed
Comments are essential tools that help you explain your code, make notes, and organize your HTML documents without affecting how your web page is displayed.
HTML comments are pieces of text that you can include in your HTML code to leave notes or explanations. These comments are not visible to users when they view your web page in a browser, but they are visible in the code itself. Comments are useful for:
To create a comment in HTML, use the following syntax:
<!-- This is a comment -->
Breakdown:
<!--
: Starts the comment.This is a comment
: The content of the comment.-->
: Ends the comment.Anything written between <!--
and -->
will be treated as a comment and will not be displayed on the web page.
<!-- This is a single-line comment -->
<!-- This is a multi-line comment. You can write comments that span multiple lines. -->
Let's see how comments can be integrated into an HTML document.
Paragraph Comment: The comment above the <p>
tag describes the purpose of the paragraph.
<!-- Introductory paragraph --> <p>This is an editable paragraph. Feel free to change this text!</p>
Image Comment: The image line is commented out. If you remove the <!--
and -->
, the image will appear on the page.
<!-- Uncomment the line below to add an image to your page --> <!-- <img src="your-image.jpg" alt="Your Image Description"> -->
Here, don't worry about how we have added image, we will learn it in upcoming chapters.
In the next chapter, we will learn about HTML elements.
.....
.....
.....