programminghead Logo

Comments in HTML :

Comments in HTML are those Texts who can be seen inside HTML Code but Ignored by the Browsers at the time of Execution. So by Using Comments in HTML we can write some Important lines as an HTML Comment without Messing with Code Output.

Comments in HTML: Example


    <!-- this is my HTML Comment -->

In more simple words Comments in HTML let us to write some texts inside the HTML Web-page, so other Person can read and get the Rough idea about the Particular line or Element.
You can assume Comments in HTML like a Guide for your HTML Code. Who will help other or Yourself to Understands your Messy or Lengthy code Easily.
Comments in HTML are Not always used as a Page guide for Our HTML Web-page. We also can use Comments in HTML to Hide some HTML Tags/Data from Browser from Execution.

Example : I Have created a HTML Document where i have a Div and inside that Div i have 20 Different Headlines. To insert those 20 Headlines inside my Div i Have to Declare those Headlines Inside my Div's Starting and Closing Tag. Due too many ( 20 ) HTML Headlines in My HTML Code, I'll became lengthy, Massey and tough to Understand and Identify Every Declared HTML Tags, Because of that i i have to use Comments in HTML to avoid Confusion with my Div's Starting and HTML tags.
for that kind of Problem i can write a little Comment after the Closing tag of my Div's at the Beginning so i can identify those Different HTML tag in Future.

Comments in HTML Image

Comment Tags in HTML:

Comment tag is Quit different then Other HTML Tags, Where in other HTML Tags we have to write our tag's name Inside these two Angle brackets < and > to create a tag, But in the case of Comments, We have to insert ! exclamation mark followed by two -- Hyphens at the beginning and two hyphens at the end without ! exclamation sign.

Syntax of HTML Comments:


    <!-- this is my Comment in HTML -->

HTML Multi-Line Comment :

Multi line Comment is just simple as Single line Comment, You just have to treat HTML Comment's <!-- starting and --> closing tag Right. Just insert one or more lines of Text inside those HTML Comment's Starting and Closing tags to make a Multi line Comment.

HTML Single and Multi line Comments Example :


  <!-- this is a Single line HTML Comment --> 

  <!-- 
  this is a Multi line HTML Comment line 1 
  this is a Multi line HTML Comment line 2
  this is a Multi line HTML Comment line 3
  --> 


Commenting HTML Elements :

Comments in HTML are not Always used as a Page Guide to write some text about any Tag or Code, HTML Comments also used to Hide any HTML code/Tag/Element from Compiler/Browsers.So Except deleting any code you can Hide that Line/Lines and Prevent that code to Export on the Output Screen.
For that you just have to Declare that HTML Code/Element inside HTML Comment's <!-- starting and --> closing tags.

Commenting/Hiding HTML Element/Code:


<html>
 <head>
  <title>HTML Comments</title>
 </head>
 <body>

  <!-- 
   <h2> HTML Headline 1 <h2>
  -->
  
  <h2> HTML Headline 2 <h2>

 </body>
</html>

Results :

HTML Headline 2

HTML Comments Example :

Whole page's Conclusion.

Inserting Comments in HTML : HTML Comments Example


<html>
 <head>
  <title>HTML Comments</title>
 </head>
 <body>
  <div> <!-- starting Div Tag -->
    <p>para 1</p> <!-- for Name Introduction-->
    <p>para 2</p> <!-- for basic Details -->
    <p>para 3</p> <!-- for Conclusion -->

    <h2>Headline 1</h2>

    <!--
    <h2>Headline 2</h2>
    -->
  </div> <!-- closing Div Tag -->
 </body>
</html>

Results

para 1
para 2
para 3

Headline 1


Frequently asked Questions :

Question : comment box in html :

Answer : HTML Comments and Comment Box inside HTML is totally Different from Each other.
Where HTML Comments are used inside HTML as a Tag to Hide or Write Comments. And Comment Box in HTML used as Interactive ELements where user can Write Comments inside Input or TextAreas and After Submitting the Data/Comment another PHP page or JS page can store those Entered data inside SQL Database.
This Page is all About HTML Comments. But if we want to Get Comments from the Users we have to use:
<form> : where users will write there Comments and submit as a form to Assigned PHP/JS file.
<input> and <textarea> : A Place where use can write There Comments.
<button> :By clicking that Button users Can Submit there Comments. php or js file : To get the Data from Users and Store Them to a SQK Database. SQL Database : to store User Comments.

Creating a Comment Box in HTML (Only the Interface)


<html>
 <head>
  <title>HTML Comment BOX</title>

  <style>
   textarea{
   width:350px;
   height:60px;
   }
   button{
   width:350px;
   }
  </style>

 </head>
 <body>

  <textarea placeholder="Write your Comment"> </textarea>
  <button>Submit Comment</button>

 </body>
</html>

Results



Question : html single line comment

In other Languages like PHP, JavaScript or Sheets like CSS we have Single line (//) and Double line Comments (/**/), But in HTML we only have one Comment tag (<!-- -->) tag which we can treat as Both Single and Multi-Line Comment Tag.
So if we want to Add a Single line Comment in HTML we have write/include that line inside these (<!-- Single Line -->) comments tags, And if we want to add Multi-Line comments then we have to write those Multi-line inside there (<!-- Multi-Line -->) HTML Comment Tags.


Question : css comment tag

In CSS We have Both Single and Multi-Line Comments Tags.
Where (//) used for Single line Comment in CSS. For adding Single line Comments in CSS we just have to add these two slashes (//) before the line that we want to Comment.
And (/* */) used for Multi-line Comments. For adding Multi-Line comments in CSS we have to start comment using with (/*) and end CSS Comment with (*/).

CSS COmment (in External .css file)


 body{
  width:100%; 
  //body is 100% Single Line Comment
  height:100vh;
  margin:0px;
  /*
   body Height is 100 equal to total View Port Height
   and
   body margin is 0
  */
 }

Question: html comment shortcut

HTML Comment Shortcut are used in Popular and Profession Text Editors line Sublime Text Editor. Where some Keys Combinations allow users to add Comments to your HTML Page.
In subline Text Editor. You have to Pres Control/Command Key (ctrl) and slash (/) to add Comments.
ctrl+/ (windows)
command+/ (Mac)



Question: Comments in JavaScript

In JavaScript we have double slashes (//) for adding a Single line comment and slash and star/asterisk sign (/*) to start and start/asterisk slash (*/) to End Multi-line comments in JavaScript.

JavaScript Comments : JavaScript Single and Multi-Line Comments (External .js file)


var data=0; //variable called data's value is 0
data++;
/*
   here (++) will increment variable data's value by 1
   so now data is equal to 1
   data++ = data+1 = data=1
*/

Question: Comments in PHP

In PHP we have double slashes (//) for adding a Single line comment and slash and star/asterisk sign (/*) to start and start/asterisk slash (*/) to End Multi-line comments in PHP.

PHP Comments : PHP Single and Multi-Line Comments


 <?php
  $data=0; //variable called data's value is 0
  $data++;
  /*
   here (++) will increment variable data's value by 1
   so now data is equal to 1
   $data++ = $data+1 = $data=1
  */
 ?>

Question: how to create a comment box in html and javascript

Creating a comment box in HTML is easy.
Just create a form using HTML's form tag <form>....</form> and between the form tag's starting and closing tags create an input field for users to write some comments, using HTML's textarea tag <textarea> and use its placeholder attribute to display some text like "enter your comment" inside that input field. and after the textarea create a submit button to submit user comment to mysql Database using PHP file.

processing user's comment using JavaScript:
Using javaScript we can store user Comment to our Database without refreshing the current page. Use JavScript's POST/GET method to submit data to a PHP file. So that PHP file can submit Data to mysql Database.

in PHP file: first create a Database connection using Username, password and Database name. After that assign POST/GET values to PHP Variables. Then run MySql query to store data to the DataBase using Table name and Column.

comment box in HTML (Interface) and javascript (Programming)


<html>
<head>
	<title></title>
	<script type="text/javascript" src="jQueryfile.js"></script>
</head>
<body>
   <input type="text" placeholder="name" id="userName"><br/>
   <textarea placeholder="Write your Comment" id="userComment">
   </textarea ><br/>
   <input type="submit" id="btn">
   <p id="return"></p>
<script type="text/javascript" >
	$('#btn').click(function(){
	$.post("post.php", 
	{
        name:$('#userName').val(),
        comment:$('#userComment').val()
    },
    function(response){
    	$('#return').text(response);
        });
	});
</script>
</body>
</html>

post.php File : For Submitting Data to DataBase


<?php
$comment=$_POST['name'];
$name=$_POST['comment'];
$db = mysqli_connect("HostName", "UserName", "PassWord", "DatabaseName");
  $sql="INSERT INTO tablename(`column1`, `column1`) VALUES ('$name', '$comment')";
mysqli_query($db,$sql);
echo "Comment Submitted";
?>

Results



Question: comment out line

Ans :
I Believe that there isn't anything Like Comment outline in HTML. In HTML Comments is a piece of code which is ignored by any web browser. We can Write some Guidelines or Hide some HTML Elements from the Browser.
But if you want to Add out Line to Any HTML Element or to a Text inside HTML we can do that using CSS's outline Property. Outline or using CSS

comment box in HTML (Interface) and javascript (Programming)


<html>
<head>
  <style>
    h2
    {
      outline: 5px dotted green;
    }
  </style>
</head>
<body>
   <h2>
     Text's Out Line
   </h2>
</body>
</html>

Results

Text's Out Line

Comments

minecraft for free

http://tinyurl.com/y6n5g6gy
03:24 am

After looking at a few of the blog articles on your site, I really appreciate your way of writing a blog. I added it to my bookmark website list and will be checking back soon. Please check out my web site as well and tell me what you think.

minecraft for free

http://tinyurl.com/y6n5g6gy
03:24 am

After looking at a few of the blog articles on your site, I really appreciate your way of writing a blog. I added it to my bookmark website list and will be checking back soon. Please check out my web site as well and tell me what you think.

minecraft download free pc

http://tinyurl.com/yy3sk4e3
09:57 am

Heya i'm for the first time here. I came across this board and I in finding It truly helpful & it helped me out a lot. I'm hoping to give one thing back and aid others like you helped me.

mojang minecraft download

http://tinyurl.com/yyfyae8o
04:59 pm

I like the helpful information you supply for your articles. I'll bookmark your blog and check again right here frequently. I am fairly sure I will be informed a lot of new stuff proper here! Good luck for the next!

g

http://tinyurl.com/yylnx5yu
08:44 pm

I am not sure the place you're getting your info, but great topic. I must spend some time finding out more or understanding more. Thank you for fantastic information I was searching for this info for my mission.

g

http://bit.ly/2HazGyQ
05:36 am

I'm really impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a nice blog like this one these days.

g

http://j.mp/2HazGyQ
08:46 pm

Hmm it looks like your website ate my first comment (it was super long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog. I as well am an aspiring blog writer but I'm still new to the whole thing. Do you have any points for first-time blog writers? I'd really appreciate it.

free minecraft download

http://tinyurl.com/yyhw4ejz
07:32 pm

Heya! I'm at work surfing around your blog from my new apple iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the outstanding work!

g

http://tinyurl.com/y6z6t5uj
08:22 pm

Its such as you learn my thoughts! You seem to grasp so much approximately this, such as you wrote the e book in it or something. I believe that you just could do with a few p.c. to drive the message house a bit, however other than that, that is magnificent blog. An excellent read. I will definitely be back.

g

http://tinyurl.com/yy98ofss
05:56 am

Keep this going please, great job!

g

http://bit.ly/2WyDujO
04:23 am

Hello my loved one! I want to say that this post is awesome, nice written and include almost all significant infos. I'd like to peer more posts like this .

how to download minecraft

http://tinyurl.com/y2lpu7cg
04:28 am

I absolutely love your site.. Great colors & theme. Did you develop this amazing site yourself? Please reply back as I'm looking to create my own blog and would like to find out where you got this from or exactly what the theme is named. Cheers!

minecraft download free

http://bit.ly/2vHEVkk
01:33 am

Right away I am going away to do my breakfast, later than having my breakfast coming over again to read more news.

minecraft download mojang

http://tinyurl.com/y6h6eo3b
04:22 pm

I was suggested this blog by my cousin. I am no longer certain whether or not this post is written via him as nobody else understand such distinct about my trouble. You are wonderful! Thanks!

minecraft free download pc

http://j.mp/2WnX5TW
03:27 pm

It's very trouble-free to find out any topic on net as compared to textbooks, as I found this piece of writing at this website.

gamefly free trial

http://tinyurl.com/y3u83zsn
06:38 am

Peculiar article, just what I needed.

gamefly free trial

http://tinyurl.com/y4j2nprd
11:59 am

A person essentially lend a hand to make critically articles I'd state. This is the first time I frequented your web page and up to now? I amazed with the research you made to create this actual publish incredible. Excellent process!

gamefly

http://tinyurl.com/y3jhe9wj
10:42 am

I appreciate, result in I discovered just what I was looking for. You have ended my four day long hunt! God Bless you man. Have a great day. Bye

gamefly

http://j.mp/2LeOly6
06:44 pm

Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is fantastic, as well as the content!

Cialis

http://costofcial.com
06:34 pm

Fantastic goods from you, man. I've understand your stuff previous to and you're just too fantastic. I really like what you've acquired here, really like what you're stating and the way in which you say it. You make it entertaining and you still care for to keep it smart. I can not wait to read much more from you. This is really a great website.

Madge

https://ruth456.sitey.me/
02:16 pm

Hi, how are you? I didn't anticipate to concur with your post, however you made some great points. Thanks!

Harriet

http://tanklitunkli.com/
11:04 pm

Have you ever before had troubles with your web host? I'm open for suggestions as my webhost is terrible currently.

Arturo

http://tunklitankli.com/
10:03 pm

Have you ever had issues with your web host? I'm open for suggestions as my webhost is awful right now.

John Cook

01:22 am

Great POST. but i'm using double slash '//' for adding Comments in CSS but it isn't working. Why?

Admin

Hi thanks for Writing to us. But the Double slash Commenting method only works in JavaScript and PHP Languages. In CSS we have to use slash star '/*' to start the comment and star slash '*/' to end the comment. Just like HTML's starting and Closing Tags.
Example
/*
height:10px;
*/

Write to Us