造梦西游五毒兽:CSS - Conditional comments

来源:百度文库 编辑:九乡新闻网 时间:2024/07/14 06:07:09

Conditional comments

show page contentsTopExampleTestCodeCSS hack?Comment tag

Loading site navigation; please wait...

Explorer 5+ Windows only.

If you have multiple Explorers installed the conditional comments will view each install as the highest installed version (usually IE 6).

This page has been translated into Brazilian Portuguese, Simplified Chinese, Russian, Hungarian, Romanian, Farsi, Italian, and Vietnamese.

Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.

Conditional comments work as follows:

  1. Their basic structure is the same as an HTML comment (). Therefore all other browsers will see them as normal comments and will ignore them entirely.
  2. Explorer Windows, though, has been programmed to recognize the special

    Note the special syntax:

    • gt: greater than
    • lte: less than or equal to

    CSS hack?

    Are conditional comments CSS hacks? Strictly speaking, yes, since they can serve to give special style instructions to some browsers. However, they do not rely on one browser bug to solve another one, as all true CSS hacks do. Besides, they can be used for more than CSS hacks only (though that rarely happens).

    Since conditional comments are not based on a browser hack but on a deliberate feature I believe they are safe to use. Sure, other browsers could implement conditional comments, too (though as yet none have done so), but they're unlikely to react to the specific query