Click here to Skip to main content
15,883,558 members
Articles / Web Development / HTML
Tip/Trick

Relative Path Solution for Master Pages

Rate me:
Please Sign up or sign in to vote.
3.67/5 (4 votes)
20 Feb 2012CPOL 19K   4
A relative path solution for master pages.

If you are having issues with your web pages not displaying background images and you are using a masterpage, the problem could be because the path to the image is relative to the page itself and not the masterpage.


To fix this issue, add a link to a CSS file in your masterpage instead of using inline styles.


XML
<link href="css/Main.css" rel="stylesheet" type="text/css" />

This makes the image path become relative to the linked CSS file instead of the page.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer JBHworks
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 1 This will not work in url rewrite pa... Pin
Mukund Thakker22-Feb-12 17:46
professionalMukund Thakker22-Feb-12 17:46 
GeneralYou can use the full url, if you have url rewrite. &lt;link ... Pin
Mukund Thakker22-Feb-12 17:44
professionalMukund Thakker22-Feb-12 17:44 
GeneralYes that is another solution but I disagree that you should ... Pin
FrostedSyntax21-Feb-12 19:21
FrostedSyntax21-Feb-12 19:21 
GeneralReason for my vote of 1 maybe a solution could be ALWAYS AVO... Pin
giammin21-Feb-12 2:56
giammin21-Feb-12 2:56 
Reason for my vote of 1
maybe a solution could be ALWAYS AVOID relative path....

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.