Absolute and Relative Links

Only available on StudyMode
  • Download(s) : 171
  • Published : June 3, 2010
Open Document
Text Preview
Absolute and Relative Links

When designing a website there are two ways for an image or file to be linked to the page. This is done be using an absolute link or a relative link. Both kinds of links must be contained within an a href attribute; however, there are some differences between two that must be considered prior to deciding which to use.

Absolute Links
As the name suggests, an absolute link defines the location of an image or file absolutely. All of the information is included in this link: the protocol, domain name, directory, and the name of the document in question. The anchor would therefore look similar to this: Homepage

Relative Links
A relative link by contrast uses a shortened version of the above anchor to get the user from one page to another. This can be accomplished because once the server knows the location of the current document it can then link to any other document in the same directory without the need of the full URL. Therefore a relative tag may look similar to this:

Because the Lake.jpg is also contained in the “site” directory there is no need to explain further. If, for example, the Lake.jpg was located in an “images” directory within the “site” directory the tag would look like this:

Likewise to link from the homepage to another page on the site the tag would look like so: Rivers

Both absolute and relative links have there place in web design. However, when designing larger web sites it will save much time and space to use relative links where ever possible to link the pages and images on the site. Absolute links should still be used when sending a user to another site.

You can see how using relative links can save you a lot of typing, especially if the source page and destination page are in the same folder on your web server. On the other hand, relative links will work even if you later move the source page to a different part of the site (although that...
tracking img