Previous Message
Next Message

relative or absolute urls?

Sent by James Gadrow on 19 June 2007 13:01


Ross wrote:
> When linking to images do you use relative or absolute urls?
>
> background-image:url(../images/myimage.jpg);
>
> or
>
> background-image:url(http://wwww.mysite.php/images/myimage.jpg);
>
>
>
>
>
> I have a common header on all pages with different folders and sub folders and the relative urls
only work for the pages in main directory but the full url means I have to change them all when
moving from local to remote hosts.
>
> I can create a common page head with php but was looking for non php solution.
>
> R.
>
>
>
> ______________________________________________________________________
> css-discuss [EMAIL-REMOVED]]
> http://www.css-discuss.org/mailman/listinfo/css-d
> IE7 information -- http://css-discuss.incutio.com/?page=IE7
> List wiki/FAQ -- http://css-discuss.incutio.com/
> Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
>
>   
As was previously suggested, root relative is probably the best way to go.
However, this is not suitable for all work environments (such as mine 
*sigh*) where your test area may be located in a sub-folder from a 
common network url.
In this case, you'll either have to bite the bullet or utilize php to 
code your page links for you.
Also, remember that all urls are relative to where the css document 
lives NOT the html/php document!

Thus if www.whatever.com/index and 
www.whatever.com/subfolder/subfolder2/page both point to the same css 
document the urls work for both!

-- 
Thanks,

Jim

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: