Skip to main content
D
HTML
HTML Comments

HTML Comments

HTML comments hide text from the browser display.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

HTML comments leave notes inside your source code. Browsers ignore comments and do not display them on the screen. Developers use comments to explain code or temporarily hide elements during testing.

Syntax

Syntax
1<!-- NOTE: reference file does not cover comments fully — placeholder used -->
2<!-- Write your comment here -->

Example

Example
1<!-- this is a comment example -->
2<!DOCTYPE html>
3<html lang="en">
4  <head>
5    <meta charset="UTF-8">
6    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7    <title>Comments</title>
8  </head>
9  <body>
10    <!-- This paragraph is hidden -->
11    <!-- <p>Hidden</p> -->
12    <p>Visible</p>
13  </body>
14</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • Comments hide text from users.
  • Browsers ignore commented code completely.
  • Comments help explain code logic.
  • Comments span multiple lines easily.

Up Next

Continue your journey with the next topic.

Go to HTML Colors