Fix CSS not loading in ASP

In this article I am going to show you how to properly load the CSS style sheets of the master page for your ASP project.


CSS files contain style rules that are applied to elements in a Web project. Usually, you can define how elements are displayed and where they are positioned on the page with CSS. If your ASP application is not looking like it is suppose to be, it must be that the CSS files are not loading properly.

Getting Started

1. Open your ASP project with Visual Studio:

asp css not loading file manager

2. Specify your stylesheet links with runat=server and prefix them with the virtual web root path (~).

It has to look something like this:

<link href= "~/css/styles.css" rel="stylesheet" runat="server" type="text/css" />

edit css header asp iis windows hosting tutorials

3. The image URL’s in the CSS file must be updated as well. If you are going to put it in the same css folder, it has to be changed to a path traversal:

traversal path asp tutorials

4. It is also a good practice to put the image folder inside the css folder. That way the path won’t have to be changed to a traversal one:

image css path asp tutorials hosting arvixe

5. Finally, please keep in mind that all head elements (JS files, Fonts, etc.) need to have the runat=”Server” element tag.

This concludes Fix CSS not loading in ASP

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez

Tags: , , , , , , , , , , , , , , , , , | Posted under ASP .NET 3.5, ASP .NET 4.0, DotNet/Windows Hosting | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

Leave a Reply

Your email address will not be published. Required fields are marked *