I'm converting a web forms application and in a code behind I see where a guy checked for IE8 browser, then displays that IE8 CSS. If I had the time I would figure out what the differences are, but for now I'm thinking that I would just like a nice clean approach in mvc 3 razor to 1. check for which browser is used ( namely IE8 ) and then display the appropriate
1 Answer
You can use a conditional tag.
<!--[if IE 8]>
<!-- include your ie8 stylesheet here -->
<![endif]-->
7 Comments
Tom Stickel
@Craig If I have a razor page with this @section Styles { <link href="@Url.Content("~/Content/default.css")" rel="stylesheet" /> } Where is a good place for your tag?
Craig M
Without seeing the rest of your code, I can't say the best place, but you can use it in your section or your layout. It's standard html, nothing asp.net or mvc specific.
Craig M
You're welcome. If that does it for you, please click the check to mark this as the answer. :)
Tom Stickel
Looking into these conditional statements, can there be an 'else' ?
Craig M
You can't do else but you can add a second conditional tag with a NOT operator. <!--[if !IE 8]> <![endif]-->
|