In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to comment the code in HTML. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
HTML comment
In HTML code, the text between the tags is the comments of the document, and the contents of the comments are not displayed on the browser page. Comments are visible only when the document is opened in a text editor or when the browser's View Source option opens.
There are two types of comments in HTML, one is HTML code comments and the other is IE conditional comments.
1. HTML code comments
In a large document, comments are used to indicate the location of the beginning and end of the block, which can be easily found, or some content can be blocked by comments.
When a large amount of code has been written, it is a good habit to comment on key code, and commenting on the intent of a piece of code can help remind yourself or others who need to work on the site to understand the purpose of this code.
It is also a good practice to use comments to hide scripts so that browsers that do not support scripts will not display them as plain text. Such as:
2. IE condition notes
IE conditional comments (Conditionalcomments) is an extension of HTML code comments by IE browsers. It is a non-standard logic statement that can flexibly import different html elements, such as stylesheets, html tags, for different versions of IE.
Conditional comments first appeared in IE5 and are supported in subsequent versions, and its syntax is a normal HTML comment that browsers other than IE will ignore as comments. Therefore, it can be verified by the W3C without affecting other browsers.
Conditional comments are so powerful that you can judge if conditions and decide whether to parse the contents of conditional comments based on whether the result is true or false.
Conditional judgment to end, can be judged according to IE, non-IE, but also according to the version number of IE, the version number can be accurate to 4 decimal places. Such as:
/ * all IE, no matter which version * /
/ * if the IE version is 6 minutes /
In condition judgment, greater than (gt:greaterthan), less than (lt:lessthan), greater than or equal to (gte:greaterthanorequal), less than or equal to (lte:lessthanorequal), or (|), and (&), not (!), parentheses are also supported. Such as:
/ * if the IE version is greater than 6 minutes /
/ * if the IE version is less than or equal to 9 percent /
/ * if the IE version is 6 or 7 years /
/ * if the IE version is not 5.5 copies /
/ * if the IE version is greater than 6 and is less than or equal to 9 percent /
With the help of conditional comments, many IE compatibility issues can be solved. For example, versions below IE9 do not support the new elements of HTML5, such as header, nav, aside, footer, and so on, and there are a large number of html5shiv scripts on Internet to solve this problem. Simply download the appropriate script, and in the page header, through IE conditional comments, let the following version of IE9 load the script, you can get these old browsers to support the new elements of HTML5.
You can also use the same approach to solve CSS compatibility issues. For example, if IE6 does not support some of the new CSS features, you can write a CSS file specifically for IE6 and just let IE6 load it:
The good news is that conditional annotations are no longer supported starting with the IE10 version. This marks that IE is becoming mature and standard, and Web designers no longer have to be bothered by the compatibility of IE.
Thank you for reading! This is the end of this article on "how to comment the code in HTML". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.