Relative and absolute linking
There are two different ways to create a link, so then how should links be formatted?
This lesson focuses on:
- Relative linking
- Absolute linking
Relative linking
Relative linking refers to linking to files that are on the same domain. With relative linking, you do not have to link to the entire path for a file.
Example:
The file html-basics.php is located at http://www.landofcode.com/html/html-basics.php and we want to link to it from a file named html-frames.php located in the same directory. Instead of creating a link to that full path, we can create a relative link to it. The relative link would look like this since the two files are in the same directory:
<a href="html-basics.php">HTML basics</a>
A relative link involves linking to a file on the same domain relative to the directory that the file linking to it is in.
Absolute linking
Absolute linking refers to linking to files using the entire path for the file.
Example:
<a href="http://www.landofcode.com/javascript/javascript-variables.php">Javascript variables</a>
Absolute linking is usually done when linking to files on another domain different from the file in which the link is located in.




