If you're using Windows 10, hold down Shift on your keyboard and right-click on the file, folder, or library for which you want a link. If you're using Windows 11, simply right-click on it. Then, select “Copy as path” in the contextual menu.
Embedding an HTML file is simple. All we need to do is use the common „<link>“ element. Then we add the value „import“ to the „rel“ attribute. Using „href“ we attach the URL of the HTML file, just like we are used to when it comes to stylesheets and scripts.
Within the same folder, just use the file name:
<a href="thefile.html">my link</a>
Within the parent folder's directory:
<a href="../thefile.html">my link</a>
Within a sub-directory:
<a href="subdir/thefile.html">my link</a>
Also, this will go up a directory and then back down to another subfolder.
<a href = "../subfolder/page.html">link</a>
To go up multiple directories you can do this.
<a href = "../../page.html">link</a>
To go the root, I use this
<a href = "~/page.html">link</a>
In addition, if you want to refer to the root directory, you can use:
/
Which will refer to the root. So, let's say we're in a file that's nested within a few levels of folders and you want to go back to the main index.html:
<a href="/index.html">My Index Page</a>
Robert is spot-on with further relative path explanations.
You can go up a folder in the hierarchy by using
../
So to get to folder /webroot/site/pages/folder2/mypage.htm from /webroot/site/pages/folder1/myotherpage.htm your link would look like this:
<a href="../folder2/mypage.htm">Link to My Page</a>
use the relative path
main page might be: /index.html
secondary page: /otherFolder/otherpage.html
link would be like so:
<a href="/otherFolder/otherpage.html">otherpage</a>
If you'd like to link to the root directory you can use
/
, or /index.html
If you'd like to link to a file in the same directory, simply put the file name
<a href="/employees.html">Employees Click Here</a>
To move back a folder, you can use
../
To link to the index page in the employees directory from the root directory, you'd do this
<a href="../employees/index.html">Employees Directory Index Page</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With