HTML Comment – Single Line and Double line HTML Comments
HTML Comment or Comments in HTML are Basically used to explain the HTML Tags or the MARKUP. It will help us and others to select or find the specific section in the document quickly and easily at the time of editing the source code. So, if somebody who knows nothing about HTML Tags / CODE, they still be able to Get an idea about HTML Tags. Like: Why we are using a Pacific tag, What's the Effect of that Tag ETC. Comments are simply ignored by the Browsers; they are not displayed by the browsers at the time of the Execution.
Adding Comments in HTML:
To insert Comments in HTML we have Comment Tags ( <!– –> ) for That. Which Allow us to Write Comments which can be Seen by Coder but Ignored by the Browser at the Time of Execution.
index.html
<html>
<head>
<title></title>
</head>
<body>
<!-- my HTML Comment -->
</body>
</html>
Hiding HTML Elements Using HTML Comments
As we all know that Browser Ignores Every Data which we Include Inside the HTML Comments Starting and Closing Tags. To Hide or Stop HTML Code to Run in Browser, we have to Put That HTML Code/Element Inside the HTML Comments Tags.
index.html
<html>
<head>
<title></title>
</head>
<body>
<!--
<p> my HTML Paragraph </p>
-->
</body>
</html>
Need a Personal Tutor?
I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.
Using HTML Comments as Code Guide
We also can Use HTML Comments as HTML Code’s Guide to make Long Codes Easy to Manage.
index.html
<html>
<head>
<title></title>
</head>
<body>
<p> <!-- P Tag Star Here -->
my HTML Paragraph
</p> <!-- P Tag Ends Here -->
</body>
</html>
HTML comment box
HTML Comments and HTML Comment Box are two Different things. Where HTML Comments are used as Page guide or for hiding/Preventing some code or line from execution.
And HTML Comments box are using for written Comments in our Web Pages.
So here we are only going to Create a Comment Box in HTML. Which can only show a Input field with a Submit Comment button. For further Execution like Comment submission and Storing user comments we have to use PHP and MySQL.
But for now, this given HTML Code will create / Insert Comment box in our Webpage using HTML.
index.html
<html>
<body>
<form action="#" method="POST">
<textarea type="text" placeholder="Enter your Comment"></textarea>
<br/>
<input type="submit"/>
</form>
</body>
</html>
HTML comment out multiple lines
For Commenting out Multiple lines in HTML we have to Write and Put those Multiple line between HTML Comment tags. Which will Comment out all the Multiple line Present inside HTML Comment Tags.
index.html
<html>
<body>
<!--
line 1 here
line 2 here
line 3 here
and so on....
-->
</body>
</html>
HTML Comment Shortcut
There are no Shortcut present in HTML to comments into our HTML Documents. You have to use the Long/Default method to Add Comments in HTML.
CODE : html comment single line
index.html
<html>
<body>
<!-- HTML Single line Comments -->
</body>
</html>
Need a Personal Tutor?
I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.
CSS comment Tag
To add Comments in CSS we have to 2 Methods for that. CSS Single Line Comment and CSS Multi Line Comments. Where [ // ] are used for Inserting Single Line Comments in CSS and [ /* */ ] are used for Inserting multi Line Comments in CSS.
index.css
// CSS Single line Comment
/*
CSS Multi line Comment
CSS Multi line Comment
CSS Multi line Comment
*/
How to create a comment box in html and JavaScript
For Creating Comment Box HTML is Enough for that. But for Further Processes line Storing User Comments we have to Use PHP or we can use JavaScript's AJAX (Asynchronous JavaScript and XML) for that. Which can get user Comment Data and Store that data in MySQL Database.
Need a Personal Tutor?
I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.