Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Relative and Absolute Links

  • It is important to note that there are two ways you can reference a document within an HREF attribute. You can reference it absolutely or relatively.

  • An absolute link defines the location of the document absolutely including the protocol to use to get the document, the server to get it from, the directory it is located in, and the name of the document itself.

  • An anchor of this type will look like those we have seen so far...

<A HREF = "http://www.eeye.com.sg/Tutorials/index.html">
here</A>

  • A relative link on the other hand takes advantage of the fact that the server knows where the current document is. Thus, if we want to link to another document in the same directory, we don't need to write out the full URL. All we need to use is the name of the file.

  • For example, if we are looking at the index.html file addressed in the previous example, and we want to link to a file called page1.html in the same directory (Tutorials), we need not write out the entire URL. In fact, either of the following anchor tags will work:

<A HREF = "http://www.eeye.com.sg/Tutorials/page1.html">
here</A>
<A HREF = "page1.html">here</A>

  • Similarly, if you wanted to link to a document in the directory "Tutorials/Chapter2/Part1" called "page23.html, you could use the following anchor:

<A HREF = "Chapter2/Part1/page23.html">here</A>

  • This is because the web server will remember the "http://www.eeye.com.sg/Tutorials" part for you.

  • One little technical note here. When you are creating a relative link to a directory under your current one, be careful not to put an initial backslash before the referenced directory. Otherwise, the server will think you are referencing the "root" directory. By example, the following link would be wrong:

    <A HREF = "/Chapter2/Part1/page1.html">here</A>
    

Additional Resources

Email Links
Introduction to Web Design | Table of Contents
Exercise Five


Up to => Home / Authoring / HTML / Tutorial




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers