Absolute Links
These links contain the entire URL necessary to resolve a link, including the protocol.
This is usually done for external links, which are links to pages outside of the current site.
Here’s an example:
<a href="http://www.google.com" title="You can find it at google.com!">google.com</a>
Document Relative Links
These links are commonly used to navigate internally within a site.
For example, if you were on the home page of your site and wanted to navigate to the contact page, you simply provide the path from the home page to the contact page.
<a href="contact.htm" title="our contact page">Contact us</a>
This assumes the contact page and the current page are in the same directory.
If the contact page were located in a directory below the current page:
<a href="resources/contact.htm" title="our contact page">Contact us</a>
To move out of a directory, use ../
:
<a href="../contact.htm" title="our contact page">Contact us</a>
Site-Root Relative Links
These are similar to document relative links, but start at the root folder for the site and then move down through directories to the desired page.
Unlike document relative links, site-root relative links are written the same no matter the current location within your site.
All links are preceded by a forward slash (/
) that refers to the root directory. Example:
<a href="/contact.htm" title="our contact page">Contact us</a>
If the contact page were deeper within the site:
<a href="/resources/contact.htm" title="our contact page">Contact us</a>