There are three ways to define the destination of a hyperlink (where ‘destination’ is a webpage, image, anchor, etc.).
The destination anchor hypertext reference (href) value, or path, can be:
An absolute link is created when the href value is a fully qualified URL, including:
http://www.yourdomain.co.nzyourpage.htmlAn absolute link to the Motive homepage looks like this:
<a href="http://www.motive.co.nz/index.php">Motive 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 Motive homepage, from this webpage, looks like this:
<a href ="../index.php">Motive 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.
The default filename varies from server-to-server (and can also be customised), usual suspects include: default.htm, index.htm, index.html and welcome.htm. Current best-practice preference is for: index.html.
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 Motive contact information, from this webpage, looks like this:
<a href ="../about/contact.php">Motive 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.
A root-relative link is created when the href value is relative to the website
root.
On the Motive website, a root-relative link to the homepage (from any webpage) is:
<a href ="/index.php">Motive 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 Motive website, the forward slash is replaced with http://www.motive.co.nz.
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.
anchor, deep-link, directory, domain name, hyperlink, HTTP, reciprocal link, referrer