Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path to folder outside of folder

Tags:

directory

path

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?

like image 429
kirby Avatar asked Dec 24 '11 18:12

kirby


People also ask

What is a relative path?

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.


2 Answers

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" />
like image 78
Cory Dolphin Avatar answered Sep 24 '22 16:09

Cory Dolphin


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!

like image 23
KarenAnne Avatar answered Sep 24 '22 16:09

KarenAnne