There are three ways to define the destination of a hyperlink (where “destination” is a webpage, image, css…).
An absolute link is created when the href value is a fully qualified URL, including:
the transfer protocol: http://
domain name: e.g. www.nuneworld.net
and filename: e.g. yourpage.html
An absolute link to the Nune homepage looks like this:
<a href="http://www.nuneworld.net/index.php">NUNE homepage</a>
An absolute href value must be used when linking between websites; when the source and destination anchors are under different domain names.
A relative link is created when the destination href value is relative to the location of the current webpage or source anchor.
A relative link to the Nune homepage, from this webpage, looks like this:
<a href ="../index.php">Nune homepage</a>
The ../ directs the browser to move (up) out of the current directory and open the file index.php.
A relative link can only be used when linking within a website; when the source and destination anchors are under the same domain name.
DIRECTORY INDEX/DEFAULT FILE
When the path does not include a filename, for example: href=’../’, the server attempts to open the directory index, or default file.
To determine which file to open, the server compares names of the files in the current directory with a prioritised list of default filenames. For example, a server may be set up (configured) to look for a file named (in order): index.htm, index.html, or default.htm. If a file named index.htm cannot be found, it will attempt to open index.html; if index.html cannot be found, it will attempt to open default.htm, etc.
If a default file match is not made, then either all files in the directory will be listed, or access to the directory will be denied (Forbidden).
A relative link to the Nune contact information, from this webpage, looks like this:
<a href ="../about/contact.php">Nune contact details</a>
The browser moves (up) out of the current directory, (down) into the about directory and opens the file contact.php.
Relative links may need to be updated if a website’s structure is changed. For example, if the about directory were renamed about-us, or contact information was moved to a new, separate contact directory, then the href value above would need to be changed.
root-relative link/root link/web-root relative link
A root-relative link is created when the href value is relative to the website root.
On the Nune website, a root-relative link to the homepage (from any webpage) is:
<a href ="/index.php">Nune homepage</a>
Beginning the href value with / (forward slash) begins the path from the root directory of the current website. The forward slash is automatically replaced with the transfer protocol and domain name of the current website. For the Nune website, the forward slash is replaced with http://www.Nuneworld.net
Root-relative href values are often used to link to files that are common to a number of webpages. For example, a root-relative href value may be used to link to a stylesheet or include file. A destination link specified using root-relative href values will continue to work, even if the source webpage is moved.
A root-relative link can only be used when linking within a website; when the destination anchor is under the same domain name.