How To Make A Comment In HTML
Last Updated : Jan 1, 2023
IN - HTML
In this tutorial we will show you how to make a comment in HTML, comments are most important feature of html. Comments are generally used by designers to hide something special content, and it may be simple lines that helps another designers to understand that is done inside the code.
We can use inline comments, single line comments and multiline like paragraph contents in html. The content written inside the comment tags is not shown on browser. We see these comment only when we see or go through source files only.
Step By Step Guide On How To Make A Comment In HTML :-
1. By using comment tag:
As, comment as used for many purposes and used by different ways by a designer in his/her webpage.
So, we go through an example to understand how different comments works and learn about them through html code .A general use of comment tag with the help of codes is given here...
<!DOCTYPE html> <html> <head> <title> Title of the document<title> </head> <body> <!-- comment starts here --> <p> two comments for developers understanding </p> <!-- comment ends here --> <p> hello <!-- this is the --> comment <!-- we can use two or more comments as we wish --> </p> <p> <!-- kjfdklja fdsfdasfdds jjlkj --> this is the multiline comment. </p> </body> </html>
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- 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.
- Thirdly, <body> tag is used to define the webpage body. All the contents to show on website are written here. Here in this code, first we use comments that are actually used by a designer for another.
- Secondly, the next comment that is used is inline comment it may be one, two or more and this comment is used inside tags and also inside content to help and used to hide secret codes also.
- And lastly, the third type of comment is multiline comment it is same as other comment but the lines of comments are more than one, o its known as multi line comment.
- For comment we have some shortcut keys. To use these, first we write line which is to be commented and type ctrl+/ or ctrl+k. which ide u use may have different key to make a text comment. But mostly used keys are these two.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.
As the <! -- -- > tags are used to make a text comment. Comments are important feature of html and it seems to be very helpful.
As first when we are as beginner then we are not able to come in touch properly but after sometime it seems to be very helpful to you also. I hope this tutorial on how to make a comment in HTML helps you.