- Comment is a piece of code which is ignored by any web browser.
- It is a good practice to add comments into your HTML code, especially in complex documents, to indicate sections of a document, and any other notes to anyone looking at the code.
- Comments help you and other understand your code and increases code readabillity.
- HTML comments are placed in between <!--..--> tags. So any content placed with-in <!--..--> tags will be treated as comment and will be complately ignored by the browser.
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<!-- I am single comment -->
<!--
This is a multiline comment and it can span through as many as lines you like.-->
<p>Document content goes here.....</p>
</body>
</html>
This will produce following result without displaying the content given as a part of comments
Output :
Document content goes here.....
Multi-line comment :
You can comment multiple lines by the special beginning tag <!-- and ending tag --> placed before the first line and end of the last line as shown in the given example below.
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<!-- I am single comment -->
<!--
This is a multiline comment and it can span through as many as lines you like.-->
<p>Document content goes here.....</p>
</body>
</html>
Comments
Post a Comment