August 21, 2009 : IN Tips & Tricks

IE Conditional browser comments in xslt – a quick snippet that will save a lot of time

IE the devil child of Microsoft

IE the devil child of Microsoft

XSLT is a great language used with XML files and is a language that we hope to cover a bit more of here on istmay. If you are new to XSLT and are dealing with stylesheets the following snippet of code could be invaluable.

<xsl:comment><![CDATA[[if IE]>
Browser rules go here as normal
<![endif]]]></xsl:comment>

You see XSLT is a very robust language and in turn can handle most of what you throw at it however it can be slightly temperamental when dealing with the browser comments. This is due to the comment code used to start the standard browser comments. Using the code above this is avoided.

In the example we’ve used if IE as the conditional comment but you can change this to check for any version of IE and you can also use the code multiple times to filter different versions of IE as you normally would.

Grab our RSS feed for more of the same ...

No Comments Yet, Care to leave one?

Add your comment