While writing an HTML document it is very important to use comments. Comments are written between an opening comment tag and closing comment tag. An exclamation sign(!) is used in the opening comment tag but not in the closing comment tag. A java script comment has two slashes(//) at the end of the comment to prevent execution. Comments are not displayed by the browsers and are very helpful in documentation. If an HTML code does not contain explanation by comments, it will be very difficult to edit the source code at a later date. No standard or event attribute is supported by the comment tag.
Why we need to write comments in an HTML document
Most of the HTML documents are very large and need frequent editing. If we find the code not explained by proper comment we will face difficulty in editing them. Comments are also very necessary to even understand the codes written by other experts. Even a document written by you will be easy to understand with the help of comments.
Sometimes we need to insert a code in an HTML document but we find that the insertion is not useful and the code in not working or creating a trouble and we have to remove it. If we have not explained the code with comments it will be difficult to find the start and end of the code.
You may like to read on - HTMLBasics-Links, Link tags Link attribs
How HTML comments are written
To write a comment in an HTML document always use the opening and closing comment tag. While inserting a new snippet of the HTML code always use comment both in the beginning and at the end. It will be the best practice to write starting and ending comment first and then write or paste the code between them. See the example below -
Write HTML comments carefully
We need to write the comments very carefully because if there is even a small error it may may cause the comment to be displayed by the browser. Any space in the comment string(Opening and closing tags) will cause the comment to be invalid.
A valid comment - <!-- valid comment --> Written carefully, There is no space.
An invalid comment < !— invalid comment--> there is space between the angular bracket and the exclamation sign.
Thank you very much for visiting this page.
You may like to read on - BloggerCSS-add drop Caps first letter big capital different color to post comments
comments in css, single line comment in html, how to comment in javascript, how to comment in html shortcut, multiline comment in html, html comment box, comment in php, What is comment tag in HTML, What is comment tag in HTML, How do you write comments in HTML, how to create a comment box in html and javascript, how to create a comment box in html and javascript,How do I add a comment section in HTML, How can we provide comments in HTML explain