How to add Comments in HTML?

In this blog post, you will learn about adding Comments in HTML. Adding Comments is very easy in HTML. Comments used in html are known as html Comments. These HTML Comments are not visible to any user. Let us learn about it in detail about it:-

Comments in HTML

The comments are used to write the explanation of the code which is not visible to the user and It helps increase the understanding of the code and make it easily readable for the coder or developer. Let us learn more about it with some examples:-

 

The syntax to add the comments is:- <!– Comment Here –>

Single Line Comment:-

Index.html

<html>
    <head>
        <title> Comments in HTML </title>
    </head>
    <body>
        <h1> Codeblockx </h1>
        <h2> Solution of all Coding Question </h2>
        <!– Find all the solution of coding question  –>
    </body>
</html>

OUTPUT

Comments in html

Multi Line Comment:-

Sometimes in HTML code, We need to add multiple lines in the comment to describe the code or any function of code. So we need to add multiline comments in it. We can use the same syntax as of the simple comment to add muti comment.  

Index1.html

<html>
    <head>
        <title> Multi Line Comment </title>
    </head>
    <body>
        <h1> Codeblockx </h1>
        <h2> Solution of all Coding Problems </h2>
        <p> Just random Para </p>
        <!–
            <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, cum magni quam non eligendi tempora minus esse illo nemo perspiciatis? Molestiae illum sequi nesciunt tempora ut eveniet quod enim. Accusamus! </p>
            How you understand it.
        –>
    </body>
</html>

OUTPUT

Multi line comment

Browser that supports Comments:-

Browser Support
Chrome Yes
Internet Explorer Yes
Firefox Yes
Opera Yes
Safari Yes

As you have now mastered this topic. You should now move a step ahead and Learn HTML in Detail. So check out the detailed blog post on it, that will definitely help you out. We have solved a large number of the most asked questions.  

 

Hope this blog post was helpful to you and you have got the answer to your question. Thank you for visiting our blog. If you have any doubts about the coding questions then let us know in the comments section we will answer them as soon as possible.

5 thoughts on “How to add Comments in HTML?”

Leave a Comment

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