Hello guys!!! Welcome to flower brackets blog. Today we are going to learn comments in html.
Now those of you who programmed in other languages would be knowing how useful comments are.
So you know if you are into the business of writing code and sharing it with people then commenting your code is extremely important.
Because you know if you do something and if you do it in a certain way then you should explain why you have done it in that way.
So that it is easier for other people to just read your code and understand what is going on.
And even if you was at your own code six months later sometimes if you have a long and complicated program it is hard for you to figure out why you have done certain things in certain ways.
In those situations if you have your code well commented then it is much easier to make sense of things.
Over here i have got a very simple html file,
Example : learn comments in html
<!DOCTYPE html> <html> <head> <title>Learn Comments In Html</title> </head> <body> <p>Welcome to Flower Brackets. Do you want to learn wordpress, java examples, html examples, java? Follow our flower brackets blog to learn more. </p> </body> </html>
In the body section i just have one paragraph of text which has the text “Welcome to Flower Brackets.
Do you want to learn wordpress, java examples, html examples, java? Follow our flower brackets blog to learn more.”
Anyway, so you know the file in web browser looks like this,
Obviously it does not do anything fancy. Just called one paragraph of text. Now let’s say i want to add comment in the above html file.
Comments you know those of you who haven’t programmed in other languages, for those guys comments are pieces of text that you insert in your html file and those pieces of text are not displayed when you open your files in any web browser and the web browser just ignores those pieces of text.
Also Read – Hover HTML Example
You can type in anything that you want as long as you are not violating the rules of commenting in html.
So let me tell you what the rules are; you get in your opening angular bracket or the less than symbol and then you get in the exclamation symbol and then you type in two hyphens. So this is the way you begin comments in html.
I know this is actually a very long process because you need four characters for it. Any way this is how you start comments in html.
You require four characters and then you can type in anything that you want to type in. Let’s say i want to type in like this,
<p>Example for comments.</p> <!-- Comments goes here -->
Comments in html can span multiple lines. The way you close comments is you get into those two hyphens again and then you just get in your closing angular bracket without getting in the exclamation symbol.
As soon as i get this closing angular bracket you would see that the text editor restores towards the color of all the tags in the text and earlier it was all light green because it is assumed that all the following text was part of the comment.
I will save this file now,
<!DOCTYPE html> <html> <head> <title>Learn Comments In Html</title> </head> <body> <p>Welcome to Flower Brackets. Do you want to <p>Welcome to Flower Brackets. Do you want to learn wordpress, <!-- Comments are pieces of text that are not displayed in web browser --> java examples, html examples, java? Follow our flower brackets blog to learn more. </p> </body> </html>
and i open in my web browser and it looks like this,
I see that nothing has changed. So google chrome has done absolutely nothing with the comment and that’s what i was expecting.
So that’s it for now. I assume you guys have understood the comment tag in html. You can subscribe to my blog flower brackets if you haven’t already.