-
Hajipur, Bihar, 844101
HTML comments are lines in your HTML code that are not displayed in the browser. They are used to:
Explain the code
Leave notes for yourself or other developers
Temporarily disable parts of code during testing
<!-- This is a comment -->
<!-- This is a heading section -->
<h1>Welcome to My Website</h1>
You can use comments to disable code without deleting it.
<!-- <p>This paragraph will not be shown.</p> -->
<!--
This is a multiline comment.
It will not be displayed in the browser.
Use it to explain complex code.
-->
✅ Inside <body>
or <head>
✅ Before or after elements
✅ Inside complex blocks of HTML code
To help others understand your code
To test code by disabling specific sections
To organize code with section labels
Don’t overuse comments — write clean code instead
Keep comments short and meaningful
Avoid leaving unnecessary commented-out code in final version
Q1. Add a comment saying “Header section” before an <h1>
tag.
Q2. Write a comment above a paragraph describing the content.
Q3. Disable a <div>
element using a comment.
Q4. Write a multiline comment explaining your HTML layout.
Q5. Add a comment to separate the header and footer sections.
Q6. Use a comment to explain a link’s purpose.
Q7. Comment out an image tag and check it disappears.
Q8. Place a comment inside the <head>
tag.
Q9. Use comments to label different sections of a web page.
Q10. Write a comment inside a form describing each input field.
Q1: What is the correct syntax for an HTML comment?
Q2: What happens to the code inside a comment?
Q3: Can comments be used to disable parts of HTML code?
Q4: Which of these is a valid multiline comment?
Q5: Where can you place comments in HTML?
Q6: Will the following code display the paragraph '<!-- <p>This is hidden</p> -->' ?
Q7: Why are comments useful in coding?
Q8: What is a good practice for writing comments?
Q9: What does the browser do with HTML comments?
Q10: What tag is used to write comments in HTML?