The path to the folder outside the folder

I have a folder for all my css in my main folder called "main". In "main" I have another folder named "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" /> 

in index.html of the math folder in which it works. I think this is because it is looking for the css folder inside the math folder. How can I link to a css folder that is not in the math folder?

+4
source share
4 answers

If I understand, your directory structure is as follows:

 siteroot main math css 

You want to set the link to the stylesheet in / main / css from / main / math / index.html.

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

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

Absolute paths are the best solution and will cause less headache in the future. I also do not know any flaws.

Alternatively, you can use ".." to move around the directory

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

For example, your directory looks like this:

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

You are in your own .css style and want to use img.png as your background image, use this:

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

It works for me!

+3
source

Use absolute path:

 href="/main/css/..." 
+1
source

You should go to the same directory as css and math using ../ Thus, it will look like ../ css / basic.css

0
source

Source: https://habr.com/ru/post/1387891/


All Articles