The instructions on HTML comment tags and conditional comments are very clear.
HTML comment tags
The comment tag in HTML is used to add descriptions or comments to code that are invisible to the browser and therefore do not affect the display of the page. The syntax of the comment tag is very simple, starting with<!--
Starting with-->
End. Comments can be used to explain the function of a code segment, to mark sections that need to be modified or are pending completion, or to place copyright information, author information, etc.
typical example
<! -- This is a comment, it does not show up on the page -- >.
<p> This is a paragraph. </p>
<! -- Reminder: need to add a new image here -->.
Conditional Notes
Conditional comments are a non-standard HTML feature specific to Microsoft Internet Explorer (IE), used to serve a particular version of HTML or CSS code to the IE browser. The syntax of a conditional comment is similar to a regular comment, but contains conditional expressions that specify which versions of IE should execute the HTML code within it.
However, it is important to note that as Web standards have evolved and browser compatibility has improved, the use of conditional comments has become less necessary and can be completely ignored in non-IE browsers. Additionally, the use of conditional comments in modern web development has been greatly reduced as Microsoft has announced the discontinuation of support for Internet Explorer and recommended the new Edge browser.
typical example
<! --[if IE 8]>
<p> This text is only displayed in Internet Explorer 8. </p>
<! [endif]-->
Although the use of conditional annotations has declined in modern web development, understanding conditional annotations is still useful when working with older sites or when optimizations need to be made specifically for Internet Explorer. However, it is more recommended to use CSS media queries and JavaScript function detection for similar functionality, as these methods offer better compatibility and wider browser support.
This article was written by Learning Together Posted!