Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Relative URLs


Relative URL locating a page in the same folder as the current page

A relative URL with only a file name links to a file in the same folder as the current page.

COURSE TEXT

Relative URLs are shorter—they don't contain every part of the URL syntax. For the parts of the syntax that aren't specified, the browser uses the parts of the current page. This is why they are called relative URLs, because their location is relative to the current page.

For example, one of the most common relative URLs only has a file name, like this:

default.htm

In this case, the browser assumes that the missing parts of the URL syntax (the protocol, server name, and path) are the same as the current page. All it has to do is find the "default.htm" file in the same folder as the current page. For a visual example, take a look at the illustration on the left.

Relative URLs are really handy for two reasons. They are shorter and therefore easier to use when inserting hyperlinks in your Web pages. And, most importantly, if you end up moving a group of pages, then you don't have to change all of the URLs if the pages are in the same, relative position to each other. Consequently, you should always use relative URLs to link to pages within your Web site.

  Go to previous page    Next Go to next page
advertisement