- Home
- /
- HTML Comments
HTML Tutorial
INTRODUCTION
HTML BASIC TAGS
INLINE & BLOCK ELEMENTS
HTML LISTS
HTML TABLES
HTML FORMS
HEAD ELEMENTS
HTML MEDIA
MISCELLANEOUS TAGS
- Home
- /
- HTML Comments
HTML Comments
In HTML, comments are like digital sticky notes you place inside your code. They help you or other developers understand what certain parts of the code do, without affecting how the web page looks or behaves. Browsers completely ignore comments – they won’t show up on your website.
Why Use HTML Comments?
HTML comments are valuable for:
- Making your code more readable and
- Leaving reminders or explanations for yourself or others.
- Temporarily disabling parts of your code for testing without deleting them.
- Adding documentation within your HTML file.
Key Facts About HTML Comments
- Visibility: Not visible in the browser (for developers only).
- Syntax: Comments begin with
<!--
and end-->
. - Shortcut Key: use
Ctrl + /
to quickly comment/ uncomment lines. - Comment Types: Supports both single-line and multi-line
Syntax of an HTML Comment
Everything inside <!--
and -->
will be ignored by the browser.
Types of Comments in HTML
HTML allows two common types of comments:
1. Single-line Comments
Used for quick notes or short explanations. These are written on a single line.
Use Case: Briefly explain what a line or element of HTML is doing.
2. Multi-line Comments
These span across several lines and are useful for:
- Adding detailed notes
- Temporarily disabling sections of code
- Explaining complex layouts or logic
Real Use example
Welcome to LearnWithArshyan
Output
No output will be shown for comments. They are only visible in the source code and help with internal documentation.

Summary
- HTML comments are ignored by browsers.
- Use
<!--
comment content-->
for creating comments. - Ideal for writing notes, explanations, or temporarily disabling parts of code.
- Improve your coding habits by regularly using comments for clarity and structure.