Take the 2-minute tour ×

I am using ASP.NET MVC 2 & C#.

I want to include/embed an html page (raw text & styling; no forms) in one of my views as is without my own css styling (read: The site.css styles for the ASP.NET MVC 2 application itself) affecting it. I can access the page statically and open it in a new window and it retains it's styling; however, if I do:

<asp:Content ID="loginContent" ContentPlaceHolderID="MainContent" runat="server">
    <!--#include virtual="~\Static\Instructions.htm" -->

The styling from the html & the site.css in the web application seem to get merged.

I've added the following ignore route entries as well:


I also tried making a partial view control with the raw html in it and rendering that here. That gives the exact same results as this.


share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

When you include a file with the code above, it's like appending the entire data into the original file, as if there was no include at all. Doing it this way, you will inherit all relative JavaScript and CSS that is on the parent file.

The only way you can solve this is by creating a wrapper around your main content and setting all the CSS elements to affect that wrapper only. Aside from that, the only other option is setting a CSS style for your appended file with specific IDs or clean up your current CSS to be more specific.

One final method, if you have CSS affecting the included file (I assume from your OP, you have CSS styling inside the file itself), you can set !important to them so that they overwrite any other CSS classes affecting them.

share|improve this answer
Not the answer I was wanting, but it was what I was expecting. All 3 of you pretty much said the same thing so I guess that's just how it is. Thanks for your input. –  jason Jul 25 '10 at 22:49
add comment

You could add a wrapper <div id="embed"> around your embedded content and then use #embed in your site.css to override the styles you don't want applied.

p {
    color: red;

#embed p {
    color: blue;
share|improve this answer
add comment

I can only suggest to do so as Pat and lighthazard said.

There's no routing problem.

Try to change your perspective to the rendered html code.

If you have a page, and there's an area, that should be in other (none) styles. then you must mark this area either by a css class, if there are many areas, or if this is the only one per page an css id.

By the way, not to style ist not possible in html. At least the browser stylesheets will define the output.

Here's en interesting Question, i hope this will help.

CSS Reset, default styles for common elements

share|improve this answer
add comment

Your Answer


