All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Single Line Comment In HTML

Last Updated : Mar 11, 2024

Single Line Comment In HTML

In this tutorial we will show you the solution of single line comment in HTML, in HTML you are able to write the code for a website. Many times when you want to change something in your website, then there a situation occurs where you don’t know where in the html codes you have to make change.

And there is also a condition when you share your html file to some other or someone sees your code from google.

Then he unable to read your code that what is done in several lines of code. Or other next lines also. Then this time you have to write comments.

Step By Step Guide On Single Line Comment In HTML :-

As, now you know that why the comments are used. Now, let us understand what comments are. Comments may be a single line or may be multiple lines in html code.

These are used to show others that what happens in this line and what goes happens in next several lines of html code.

Actually, the fact behind comments is that the comments are not showed on browser when you open html code on browser. But these are seen from coding.

Today, we will show you that how you are able to make single line comments in html

 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
</head>
<body>
       <!-- this is one line of comment, you can also say it single line -->
    <!-- <p> this is paragraph tag, you can also make any tag comment for later use </p> -->
    <!-- <h1>
        you can also make multilines comments
    </h1>
    <h3>
        this topic can be described in next session
    </h3> -->
</body>
</html>
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Thirdly, <body> tag is used to define the webpage body. All the contents to show on website are written here. Hence, here in body all the contents are comments. When you run this code, you see nothing on browser screen.
  5. You can make any line comment by using <!-- --> , these tag are used to make a single line comments in html and also can be used to make multiple line comments which can be discussed in next session. You can also make a tag with content as comment for later use by using same tags.
  6. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

At last, here we can say that with the help of this article. We are able to make single line, in this code we also give an example of multiline comment.

Which is discussed properly in next session. I hope this tutorial on single line comment in HTML helps you.

Author Image About Riya

A recent graduate with a Bachelor of Technology (B.Tech) in Computer Science from India. She is passionate about leveraging technology to solve real-world problems. With a strong foundation and experience in programming languages such as Python, Django, HTML, CSS, and JavaScript, java, php and have honed her skills through hands-on projects and coursework.

Follow Riya On Linkedin 🡪