Htm,css,javascript and other ways of commenting

Source: Internet
Author: User
Tags html comment

Transferred from: http://www.cnblogs.com/dapeng111/archive/2012/12/23/2829774.html

First, the HTML annotation method
<!--HTML comments: START-to-
Content
<!--HTML comments: END--

The content that is contained between <!--and--is ignored by the browser and is not displayed in the user's browsing final interface.

The part of the comment is ignored while the browser is executing, but you can still see it when you view the source code in the browser

Second, the CSS annotation method
<style type= "Text/css" >
/* CSS Comments */
</style>

This method annotation is also used in a separate CSS style sheet file

Three, JS's annotation method
<script type= "Text/javascript" >
The single-line annotation method of JS

/*

This is JavaScript.

Multi-line Comment mode

*/
</script>

Write in JS

<!--

-

The roles and causes are as follows:

JavaScript recognizes the beginning of the HTML comment "<!--", and JavaScript ends it as a single-line comment, as with "//". But JavaScript does not recognize the result part of the HTML comment "--".

Therefore, if the first line starts with "<!--" and the last line ends with "//-->", JavaScript ignores both lines without ignoring the parts between the two rows. And if in JavaScript, the first line starts with "<!--",

The last line ends with "--" and the program is included in a full HTML comment that is ignored by browsers that do not support JavaScript and cannot be displayed.

In this way, you can hide code for browsers that don't understand JavaScript, and browsers that understand JavaScript don't have to be hidden.

Iv. annotation Methods for ASP

<%
Set xml=server.createobject ("Microsoft.XMLDOM")
Set Fs=xml.documentelement.childnodes
' ASP comments
%>

Five, the JSP annotation method

The comments in the JSP are divided into two types of annotations:
· Explicit Comment: Comment "<!--comment in HTML"--"
· Implicit annotations: You can use "//", "/*....*/" in Java, and your own comments in JSP: "<%--Comment content--%>"
The so-called explicit or implicit actually refers to the code that is displayed when the source file is viewed.
<%--annotations in JSP, invisible--%>
<%
Note, invisible
/*
Note, invisible
*/
%>
<!--explicit annotation--

Additional comment methods:

such as VBS annotated content with ' notes or REM '

PHP supports c,c++ and UNIX-style annotation methods:

/* c,c++ style multi-line Comment */

C + + style line Comment

# UNIX Style single line comment

Htm,css,javascript and other ways of commenting

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.