Jump to content

Recommended Posts

Posted (edited)

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?

Edited by maskull
Posted

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?

Posted
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 :).

Posted
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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...