• Breaking News

    Business

    Tuesday, July 28, 2015

    Writing comments in HTML and need to write a comment in HTML document

    Writing comments in HTML and need to write a comment in HTML document-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. 
    Writing comments in HTML and need to write a comment in HTML document
    Writing comments in HTML 

    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. 

    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 or paste the Entire code here 
     

    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 - 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. 


    No comments:

    Post a Comment

    Fashion

    Beauty

    Travel