Path to folder outside of folder

If I am understanding, your directory structure is as follows:

siteroot
    main
       math
       css

You are looking to link to a style sheet in /main/css from /main/math/index.html.

There are two solutions, the easiest is to use an absolute path:

  <link rel="stylesheet" href="/main/css/basic.css" type="text/css" media="screen" />

Absolute paths are a better solution and will cause less headache down the road. I do not know of any drawbacks, either.

Alternatively, you could use '..' to traverse up a directory

 <link rel="stylesheet" href="../css/basic.css" type="text/css" media="screen" />

For example your directory is like this:

Desktop >
        ProjectFolder >
                      index.html
                      css        >
                                 style.css
                      images     >
                                 img.png

You are at your style.css and you want to use img.png as a background-image, use this:

url("../images/img.png")

Works for me!

Tags:

Directory

Path