HTML comments (Comments)
HTML comments (comment) Tags (tag) are used to write comments in your HTML document. The comments will be ignored by the browser and will not be displayed on the screen. Annotations are usually used to illustrate or remark your HTML code, so that you can look back after a while or other co-workers can know why you wrote the HTML in this place in the first place.
HTML annotation symbols are used <!--and -->before and after wrap your notes, for example:
Here is the comment text, it will only be seen in the HTML code and will not appear on the screen -->
HTML multi-line comment (multi-line comments) with a single line comment is the same, in fact, as long <!--and -->all content will be treated as middle notes:
<!--
Here is a multi-line comment
Here is a multi-line comment
Here is a multi-line comment
-->
HTML Conditional Comments
Conditional annotations are mainly for Microsoft's Internet Explorer browser. The usage of conditional annotations is to let a specific version of IE know to read and execute the content in conditional annotations, while other IEs that do not meet the conditions Versions or non-IE browsers will treat this as a general comment and skip the content in the comment.
for example:
<link href="everything.css" rel="stylesheet">
<!--[if IE]><link href="legacy-ie.css" rel="stylesheet"><![endif]-->
The above example means that only the IE browser will download the legacy-ie.css style sheet.
The conditional expression syntax is annotated <!--[if IE]>and <![endif]-->composed, which at the beginning of the label in brackets is called a "condition"!
| condition | Description |
|---|---|
<!--[if IE]>內容<![endif]--> | Will execute content for all versions of IE |
<![if !IE]>內容<![endif]> | Only IE will not execute content |
<!--[if IE 7]>內容<![endif]--> | Only IE 7 will execute the content |
<!--[if IE 8]>內容<![endif]--> | Only IE 8 will execute the content |
<!--[if lte IE 7]>內容<![endif]--> | less than or equal to only IE 7 (inclusive) will execute content below |
<!--[if lt IE 8]>內容<![endif]--> | Less than only IE 8 (not included) will execute the content below |
<!--[if gte IE 7]>內容<![endif]--> | greater than or equal to only IE 7 (including) and above will execute content |
<!--[if gt IE 7]>內容<![endif]--> | greater than only IE 7 (not included) and above will execute content |
You can also use () & |a more complex conditions to the combination, such as:
<!--[if (gt IE 5)&(lt IE 7)]>
<p>You are using Internet Explorer 6.</p>
<![endif]-->
Post a Comment
0 Comments