Search code examples
htmlasp.netcsswebformsconditional-comments

How to wrap multiple asp.net web form <html> tags in conditional comments?


Working with a legacy asp.net web app, is there a way to add conditional comments around two <html> tags, while still maintaining runat="server" attributes? (Server side browser detection, re-writing the rendered control, and client side css class additions aren't options). The following does not work...

<!--[if lt IE 9]>
     <html class="old-ie" runat="server">
<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
     <html runat="server">
<!--<![endif]-->

this doesn't work either...

 <html runat="server" <!--[if lt IE 9]>class="old-ie"<![endif]-->>

An exception will be thrown in both cases.


Solution

  • In the end, I decided to just use conditional comments around a stylesheet, rather than trying to decorate the <html> tag with IE-specific css classes.