Welcome to the chapter 6 of our HTML Tutorial series.
In the last chapter we learnt about HTML Text Styles and Formatting. In this chapter we will learn about Comments in HTML.
HTML Comments are used in HTML documents in case you want to add an HTML code but do not want the browser to render it. It basically means when the HTML file is viewed over the browser, the content within the comment will be hidden from the user. The comment will be visible only in the source code of the HTML file.
Why do we need Comments in HTML?
As a Web Developer, you may want to use comments in HTML for multiple reasons:
Syntax:
The general syntax for adding an HTML comment is given below for reference:
<!-- This is an HTML comment -->
The comment starts with “<!--" and ends with “-->”.
Things to remember:
Here are some points to note regarding HTML comments:
<!--
<p> This is line 1 which is commented</p>
<p> This is line 2 which is commented</p>
-->
<p> This is line 3 which is not commented</p>
<p>This is a paragraph containing <!-- a hidden text --> inside it</p>
You can try running these code snippets on our Online HTML Editor to view the output.
I hope this tutorial was helpful. See you soon in our next tutorial.
Next Chapter Chapter 7 - HTML Hyperlinks
Fully customizable CRM Software for Freelancers and Small Businesses