HTML Comments

By | January 4, 2020

Any HTML code has a specific purpose. We do not know which code is written for whom, therefore we use a comment which is called HTML comment.

<!-- ... -->

Browser ignores anything written between these tags that is it does not show on the web page. When we write a content, before that, in the comment, we write about that which makes the code easier to understand.

Example:-

<!-- THIS IS H1 HEADING -->
<h1>This is h1 Heading.</h1>

In the given example, the content written in <!– THIS IS H1 HEADING –>will not show on the browser as it is a comment while the content written in <h1> will show on the web page.

Example:-

<!DOCTYPE html>
<html>
<head>
	
<!-- Internal CSS -->

<!-- style tag start -->
<style>
	h1{
		color: red;
	}
	p{
		font-size: 20px;
	}
</style>
<!-- style tag end -->

</head>

<!-- body section start -->
<body>
	
	<!-- Heading Tag -->
	<h1>First Heading</h1>

    <!-- Paragraph tag -->
	<p>Lorem ipsum dolor sit amet.</p>

	<!-- Click The Link -->
	<a href="https://learnhtmlcoding.com/">Click Link</a>

</body>

<!-- body section end -->

</html>

Multiline Comment:-

In the HTML code we often need to comment multiple lines, which we can also name multiline comments.

Example:-

<body>

<!-- Multiline Comment
Lorem ipsum dolor sit amet,
 consectetur adipisicing 
 elit. Quibusdam, iste!
-->

<!-- Multiline Comment

<h2>This is heading</h2>
<p>Lorem ipsum dolor sit.</p>

-->
</body>
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *