How to place a hyperlink "two levels higher in the directory tree"?

I am trying to encode my home button. Is there a way to simply recreate the file structure, instead of using an absolute path like mine below.

I have an index.html file that I have in C:\Users\Randy\Documents\XML\

Here is my code:

 <a id="my-family" href="C:\Users\Randy\Documents\XML\index.html">Home</a> 

This is where I am trying to come: C:\Users\Randy\Documents\XML\project\xml

+6
source share
5 answers

You can use ../index.html to refer to index.html in the parent directory.

+15
source

to go up two levels, use "../../" and your normal two-level url up.

"../" is used one level up in the path. But it can be used again to increase the level.

example:

 | HOME <br> +- image.jpg<br> |_ | +- CONFIG<br> | + PICTURE_CONFIG | +- myfile.html 

myfile.html contains:

 <img src="../../image.jpg" /> 

the second "../" goes from PICTURE_CONFIG to the CONFIG folder
first "../" from the CONFIG to HOME folder
"image.jpg" searches the HOME folder for the file "image.jpg"

+13
source

I'm not sure exactly what you are asking for, but in relative ways ../ is on the same level.

So ../index.html will lead you to the next directory index up. Hope this helps.

+2
source
  • <img src="picture.jpg"> WHEN picture.jpg is in the same folder as the current page

  • <img src="images/picture.jpg"> WHEN picture.jpg is in the folder with images located in the current folder

  • <img src="/images/picture.jpg"> WHEN picture.jpg is located in the images folder located in the root folder of the current website

  • <img src="../picture.jpg"> WHEN picture.jpg is in the folder one level higher than the current folder

    1. <img src="../../picture.jpg"> WHEN picture.jpg is in the folder two levels up from the current folder

Hope this example helps :)

Source: https://www.w3schools.com/html/html_filepaths.asp

+1
source

It works for me to return to two levels (parent folder) via a hyperlink link.

-3
source

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


All Articles