cnsHomeSearch
cns

Absolute and Relative URLs

An Hypertext Markup Language (HTML) file can reference other files, primarily in IMG and A tags. Such references are done using Uniform Resource Locators (URLs), and can be either absolute or relative, based on whether a complete or partial address is used. Relative URLs are generally preferred because they allow a document to be moved to a different server or directory and work unchanged.

K-State's recent move of personal pages to the www-personal.ksu.edu server will cause people to have to change any absolute links in their HTML files. Absolute links could simply be updated to use the new server. In other words, simply change www.ksu.edu in HTML files to www-personal.ksu.edu. However, using relative links is a better method.

Example Home Page with Absolute URLs

The following simple home page has two absolute URLs: one in an IMG tag and one in an A tag.

<HTML> 
<HEAD> 
<TITLE>Neil's Home Page</TITLE> 
</HEAD> 
<BODY> 
<H1>Neil's Home Page</H1> 
Here is a picture of me: 
<CENTER> 
<IMG SRC="http://www.ksu.edu/~neil/portrait.gif"><== absolute link
</CENTER> 
<P> 
Also, check out my 
<A HREF="http://www.ksu.edu/~neil/hobbies.html">hobbies</A>.  <== absolute link

For use with the www-personal.ksu.edu server, this file should be changed to use relative links:

<HTML> 
<HEAD> 
<TITLE>Neil's Home Page</TITLE> 
</HEAD> 
<BODY> 
<H1>Neil's Home Page</H1> 
Here is a picture of me: 
<CENTER> 
<IMG SRC="portrait.gif"><== relative link
</CENTER> 
<P> 
Also, check out my 
<A HREF="hobbies.html">hobbies</A>.  <== relative link

start of standard bottom bar
Home        Search        Directories        Calendar        Comments
Kansas State University
May 31, 2002