last update : 17 Januray 2012
Many web designers use browser detection techniques to ensure that their sites display properly when viewed with specific browsers. Often Internet Explorer prior to version 9 is focused by developers because of bugs or lack of support of new css features. The most common way to detect Internet Explorer is to use client-side scripting to parse the user-agent string and extract the version number from the version token. If one is specifically interested in Internet Explorer, conditional comments might be a more effective alternative.
Conditional comments are a simple Internet-Explorer-only feature that Microsoft added to IE5 Windows and later. They provide an easy way to detect what IE browser a visitor is using to serve him different blocks of HTML.
There are two types of conditional comment: downlevel-hidden and downlevel-revealed. Downlevel-hidden comments hide HTML from non-IE browsers and from down-level IE browsers. The basic syntax of a downlevel-hidden conditional comment is :
<!--[if expression]> HTML <![endif]-->
expression can contain a number of different operators and values.
The downlevel-revealed conditional comment enables you to include content in browsers that do not recognize conditional comments. The basic syntax is :
<![if expression]> HTML <![endif]>
Conditional comments are usually used to load specific css or javascript files.
Conditional comments produce valid W3C code.
More informations about these topics :