Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    DMN
    DMN is offline
    New Coder
    Join Date
    Dec 2012
    Posts
    18
    Thanks
    1
    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:

    Code:
    CSS/Style.css
    Any help will be appreciated, thanks.

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

    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
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    Parent_Folder
                 |__ CSS
                 |       |__ style.css
                 |__Genral_Use
                              |__ 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
    •