Reputation: 12012
Using C#
In my webpage style sheet is not loading, i am using Google Chrome Browser
Code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Data Entry</title>
<link rel="stylesheet" href="G:/style.css" type="text/css" charset="utf-8" />
</head>
</html>
The above code is not loading the style.css file.
How to solve this issue.
Upvotes: 2
Views: 137
Reputation: 499392
Your HREF is incorrect:
href="G:/style.css"
You need to either use a relative path:
href="../style.css"
Or if you must use a file URI, use the correct one - this will mean only people with the correct browser/operating system and with G
drive can see the stylesheet:
href="file:///g:/style.css"
Upvotes: 3
Reputation: 13230
if it has to be on the file system:
href="file:///g:/style.css"
If your stylesheet is in the same folder as Default.aspx, use
<link rel="stylesheet" href="/style.css" type="text/css" charset="utf-8" />
In this case, the leading slash '/' is important because it points to the root of the domain, so if you page url is http://localhost:8000/folder/anotherfolder/page.aspx
, then the href="/style.css"
will still point to http://localhost:8000/style.css
, not http://localhost:8000/folder/anotherfolder/style.css
. This means that all of your pages will point to the same stylesheet in the same place.
If your stylesheet is in a sub folder of the application root such as css/, use
<link rel="stylesheet" href="/css/style.css" type="text/css" charset="utf-8" />
If it really is in G:/, copy it to the root of your application and use the first example above.
Upvotes: 0