Topic: URL question

Hi. I'm new to web design and am currently struggling to understand a simple URL reference. I hope someone can explain it to me. I encountered the following import statement:

@import "/pathxyz/abc.css"

I understand that ../ references the parent folder and that pathxyz/abc.css points to the abc.css file in the pathxyz folder, but what does the starting / in the above URL point to? Am I asking the right question? What exactly is that URL saying to me?

Last edited by maskull (2009-10-07 12:44:46)

Re: URL question

the "/" goes all the way back to the root folder, no matter which page the link is placed in.. For example:

You have this link "/image/img.jpg" on your page http://www.yoursite.com/folder/folder/file.html. The folder your file.html is in doesn't matter -- the link is going to go all the way back to the root (www.yoursite.com/) and then look in the images folder for the image (www.yoursite.com/images/img.jpg).

Make sense?

Re: URL question

Clear as glass! But how does that work locally? If I'm on file:///C:/temp/file.html, for example, what part is the root? Is it file:///C: ?

Re: URL question

I imagine it would be "file:///C:/" but I'm not 100% sure. Just test it by creating a link to "/" and see where it takes you.

In general, I try to avoid using an opening "/" while working on a local machine...

Re: URL question

falkencreative wrote:

In general, I try to avoid using an opening "/" while working on a local machine...

That was exactly my quandary. I got the code from a very reputable (and, dare I say, very famous) site, and it confused me to no ends at first. But after your clear and concise explanation, I understand why they did it that why. I won't go into it any further and simply close with a THANKS smile.

Re: URL question

Sure thing, glad to help. smile

Re: URL question

Hey, I didn't know that. So if I was two folders deep, instead of saying ../../ to get back to the root, I could just use /  ?

Re: URL question

Eric wrote:

Hey, I didn't know that. So if I was two folders deep, instead of saying ../../ to get back to the root, I could just use /  ?

Yes. As I pointed out above though, this sometimes can cause issues when working on a local machine.