HTML Comments
The comment tag (<!– Comment –>) is used to insert comments in the HTML code. It is a good practice of coding so that coder and the reader can get help to understand the code. It is helpful to understand the complex code. The comment tag is useful during the debugging of codes.
- It is a simple piece of code that is wiped off (ignore) by web browsers i.e, not displayed by the browser.
- It helps the coder and reader to understand the piece of code used for especially in
- complex source code.
<!-- Comments here -->
Types of HTML Comments:
There are three types of comments in HTML which are:
- Single-line comment
- Multi-lines comment
- Using <comment> tag
Single-line comment:
<!DOCTYPE html>
<html>
<body>
<!--This is heading Tag -->
<h1>GeeksforGeeks</h1>
<!--This is single line comment -->
<h2>This is single line comment</h2>
</body>
</html>
Multi-line comment :
Multiple lines can be also used by using the (<!– –>).
<!DOCTYPE html>
<html>
<body>
<!-- This is
heading tag -->
<h1>GeeksforGeeks</h1>
<!-- This is
multi-line
comment -->
<h2>This is multi-line comment</h2>
</body>
</html>
Using <comment> tag:
There used to be an HTML <comment> tag, but it is not supported by any modern browser.
<!DOCTYPE html>
<html>
<body>
<comment>This is heading tag</comment>
<h1>GeeksforGeeks</h1>
<comment>This is multi-line
comment
</comment>
<h2>This is a comment using</h2>
</body>
</html>
0 comments:
Post a Comment