In real life, when you read an article or watch a YouTube video, there is a comment section where you write your thoughts about what you have seen or read.
In the same way, when a developer comments are added in the code section to explain what the code does or what it is for.
Developers also use comments to write notes or temporarily hide elements while creating webpages.
In short, comments are to make the code easy to understand.
There are two types of comments, which are listed as follows:
Single-line comments
If you write a comment that is small and fits in one line, it is called a single-line comment.
Syntax:
<!-- This is a single-line comment -->
Example:
<p>This is a paragraph.</p> <!-- This is an example of a single-line comment -->
Output:
Multi-line comments
If you write a comment that is long and does not fit in one line, it is called a multi-line comment.
Syntax:
<!-- This is a multi-line comment It can span multiple lines -->
Example:
<p>Hello World</p> <!-- This is a comment written in multiple lines -->
Output:
