Tuesday, November 5, 2024

Relative and Absolute Hyperlinks

You may have heard the terms “absolute” and “relative” in relation to hyperlinks and file paths. So what exactly are they and is there any real difference or benefits in using a particular type?

What is a relative hyperlink?

Relative links are most often used when pointing to a page within the current site. They are coded based on the relation between the current page and where the target page is located within the web.

For example, if you were to link one page to another page in a current directory or folder, it would look something like this:

Web site hosting plans

If you were linking from a page to a page in another folder, with that folder being directly under the root directory:

Or for another twist on that example:

Web site hosting plans

.. which basically means “start at root document directory, “hosting” folder, hosting-packages.htm file”

What is an absolute hyperlink?

An absolute link is the full URL path to the target page. This is most commonly used to point to resources outside of the current site e.g:

ThinkHost Affiliate Program

Note: in the case where your domain name has subdomains, then absolute linking must be used between the main domain and the sub-domain or vice-versa. The subdomain is considered a different site altogether.

Relative vs. Absolute within your own site

Given that both methods of linking will work for linking pages within your own site, there are definitely benefits to using relative links.

1) If you should change your domain name, you won’t have to change your linking structures.

2) Page location speed. By using relative linking methods, it doesn’t take quite as long for browsers to fetch pages as requests like “go up one level and fetch x page” are made, rather than “find site, go to folder, retrieve x page”.

3) Page size. If your pages have many links pointing to different sections of your site, you can save a couple of kilobytes in coding on each page. This will save on bandwidth and assist your pages in loading quicker.

4) Most WYSIWYG web page editing applications such as DreamWeaver and FrontPage will automatically update links if you should change a file name when the links within the web are coded in a relative way.

5) Offline testing of your pages before publishing is much simpler as link testing can be carried out on the copy of the site stored on your hard drive.

Michael Bloch is the Business Operations Manager of ThinkHost, a USA based company that has been providing hosting solutions to the world since 1999.

Related Articles

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles