It's sometimes nessasary to write conditional commenting in (X)HTML or in CSS, especially with the current browser wars. Here, i describe how to write conditional commenting enabling/diabling IE from rendering. With some witty programming you can make IE/Win work in somewhat standards.
(X)HTML Commenting
Global IE/Win
<!--[if IE]> <link rel="stylesheet" href="IEwin-stylesheet.css" type="text/css" /> <![endif]-->
Less Than or Equal to IE6/Win
<!--[if lte IE 6]> <link rel="stylesheet" href="IE6win-stylesheet.css" type="text/css" /> <![endif]-->
Show for ALL browsers except IE/Win
<![if !IE]> <link rel="stylesheet" href="MozillaStylesheet.css" type="text/css" /> <[endif]>
Try it
<p>Output 1: <!--[if IE]>Hello. You're on IE. <![endif]--></p> <p>Output 2: <!--[if !IE]><!-->Hello. You're <strong>not</strong> on IE.<!--><![endif]--></p>
Output 1:
Output 2: Hello. You're not on IE.


0 Responses to “Valid XHTML Conditional Commenting”