Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2012
    Thanked 0 Times in 0 Posts

    How to Use Relative Path

    Hello All,
    Suppose I have a folder called Parent_Folder and inside of it there are two folders namely, CSS and General_Use. There is a subfolder inside of the General_Use folder called subFolder1 which contains a webpage. If this webpage needs to link to a style sheet in the CSS folder, what would the path to the style sheet be? I have tried the following without success:

    Any help will be appreciated, thanks.

  2. #2
    New to the CF scene
    Join Date
    May 2013
    Thanked 0 Times in 0 Posts
    Looking at what you've said above the relative path for to load your CSS should be:

    Each ../ represents a directory. It basically means move up a directory. So in your case you need to go up how many directories to get to the CSS folder and then get into it to access the style sheet? The Answer is two then access a folder in there.

    So you need to go up two levels to access the CSS folder so therefore you need two ../ parts. Somebody could probably explain it better than I have but you should be able to use the code above to load your CSS.

  3. #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Thanked 2,250 Times in 2,237 Posts
                 |__ CSS
                 |       |__ style.css
                              |__ subFolder1
                                        |__ webpage.html
    It would be ../../CSS/style.css, where ../ denotes the parent folder.

    btw, if you could define Parent_Folder as the root folder of your site, you may easily use the absolute paths, beginning with a /, to refer any elements like images, scripts, css files etc. Thus, in your case, it'd /CSS/style.css
    Last edited by abduraooft; 05-07-2013 at 11:34 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts