Blog of Steve Savage A blog for business analysts and architects, and fellow user's of Sparx's EA

23Nov/030

Creating XHTML complient downlevel-revealed conditional comments

Problem addressed

Downlevel-revealed conditional comments do not validate

Solution

Wrap the downlevel-revealed tags (visible to non-WIN IE browsers) in downlevel-hidden start and end tags (treated as comments by non-WIN IE browsers) to hide them from validators

<!--[if IE]><![if !IE]><![endif]-->
	Hidden from IE
<!--[if IE]><![endif]><![endif]-->

Treated the same in IE as:

<![if !IE]>
	Hidden from IE
<![endif]>

Background

Supported by WIN IE 5.x +,
I mainly use this to target code/css to specific versions of WIN IE.

I currently use
downlevel-hidden conditional comments
for my browser specific style sheets.

I prefer conditional comments to the popular but
problematic css hack filters that
rely on browser bugs that may or may not get fixed.