Search code examples
pathdirectory

Path to folder outside of folder


I have a folder for all my css in my main folder called "main." In "main" I have another folder called "math." I would like to use my css in the "math" folder, but when I type:

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

on the index.html of the "math" folder it doenst work. I think it's because it's looking for the css folder inside of the math folder. How can i link to the css folder, which is not in the math folder?


Solution

  • 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" />