Html – How to put a hyperlink to “two levels above in the directory tree”

htmlhyperlinkrelative-path

I am trying to code my Home button. Is there a way to just climb back up the file structure, instead of using the absolute path like I have below.

I have a file index.html that I have at C:\Users\Randy\Documents\XML\

Heres my code:

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

Heres where I am trying to come from: C:\Users\Randy\Documents\XML\project\xml

Best Answer

to go two level up use "../../" and your normal url from two level up folder.

"../" in the path is used to go one level up. But, it can be used for more times, to go more levels up.

an 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 CONFIG folder
the first "../"goes from CONFIG to HOME folder
"image.jpg" searches in HOME folder for the file "image.jpg"