Forum Moderators: not2easy

Message Too Old, No Replies

relative linking

         

icpooreman

9:02 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



This is prob not a css question but I'm looking to link all of my pages which are located in dif directories to the same css/image files. Now I'm testing on my local machine now and don't have a url so I need a relative path.
instead of using www.example.com/css/styles.css I was told to use a relative path starting in my root dir like so /css/styles.css so that I can have a template to build my pages on so if I put a page in a deeper dir I don't have to add another ../

Now my problem is that the /css/styles.css doesn't link correctly and I'm assuming the original / isn't starting at the folder I want it to. I can get it to work if I type in C:\mycomp/etc.etc. Is there a way to declare which folder is my root dir? Can I do so in the doc. itself w/ html or css? Anything would be helpful because I've got a good amount of sites I plan to build in dif directories all linking to the same images and css files and I'd like to have a template for all of them.

[edited by: tedster at 12:13 am (utc) on July 8, 2005]
[edit reason] use example.com for domain name [/edit]

garann

9:59 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



The <base> tag might get you part of the way there. You'd still have to specify it for each page individually, but having done that, all the paths within the page could be relative to the root. On the other hand, you'd have to go back through and remove or change those tags before publishing the website.

You could also set up a test server on your own machine, which is probably the best thing to do. That way, you're coding the right paths from the get-go and you'll be able to see your CSS and images while still on your development machine.