Relative or Absolute Addressing

Quick simple note about relative and absolute addressing issue.

Relative addressing means the link paths are set up to be relative to the directory where the current page resides. For instance, “images/gif/btn.gif” exhibits relative addressing, in which the file is in the subdirectory “gif,” which is under the “images” subdirectory, which is in turn under the directory in which the current HTML document resides.

Furthermore, using “../” at the beginning of the reference sends the browser up a level, so that “../../gif/btn.gif” sends the browser up two levels from the location of the current page, and then down to the “gif” directory where the file is located.

Absolute addressing, conversely, means that each page is accessed independently, via the full URL. The absolute address for the aforementioned image might be “

The problem with absolute addressing is that if you move the site, either from your local machine to the web server or to an entirely new web server, all the links break. Such moves necessitate updating every absolute address to point to the new location, often a time-consuming and error-prone task. On the other hand, relative addressing should work flawlessly regardless of where the site happens to be located, as long as the site’s directory and link structure remain unchanged.

Although you have no choice but to use absolute addressing for links to pages outside of your site, make sure to use relative addressing for all links to pages within your own site.

There have been no comments | Subscribe to Comments | Jump to Form »

Post Comment on This Article

Your e-mail address won't be published. If you simply add some value to the original post and stay on the topic, your comment will be approved.

You can use Textile parameters on your comments. For example: _italic_ *bold* bq. quated text "link text":URL — Get your own picture next to your comment with a Gravatar account.