An absolute link shows the entire destination address in the link tag. This exact destination address is referred to as an absolute path. You might be thinking but why cannot we use just the file name or just the relative path? Well, the relative path (see creating relative links for more information) is only good for linking to files that are in the current folder. To link to files which are outside of the current folder, an absolute path needs to be used. Thus an absolute link is used for linking to files that are outside of the current folder; a relative link is used for linking to files that are within the same folder. An absolute link is also used for linking to other websites.
Let's first work with an example that uses an absolute path of a file for creating a link within the same website. The second example will show you how to create a link to an external website.
Figure 2 Absolute Link
In this example, we have two folders: ASP and HTML. If we link Active-Server-Pages.asp file to the HTML-introduction.asp file, we would need to reference the folder name because the HTML-introduction.asp file is outside of the ASP folder.
So for the first example assume that we have two folders: asp and html. Assume further that we have one web page in each of these two folders : asp folder contains a file named Active-Server-Pages.asp and the html folder has a file called HTML-introduction.asp. See figure 2. To create a link from the Active-Server-Pages.asp file to the HTML-introduction.asp file, we would need to reference the folder name and the file in our link tag:
<a href="html/HTML-introduction.asp">Introduction to HTML</a>
What does the above link tag mean? It starts with the usual anchor tag (<a>), which is required when linking to other documents. Next, to instruct the computer which document we want to link to, we use the HREF property that contains the destination document. The destination document is a folder named html and a file named HTML-introduction.asp. "Introduction to HTML" is the link text for this example. Output: Introduction to HTML.
In our second example, we will create a link to http://www.google.com. To create any link in HTML, we have to use the anchor tag with the HREF property. To create a link to www.google.com, we use the following code:
Notice in this example the HREF property starts with "http://www." because we want to link to a webpage that is outside of our current website. The domain name (in this case google.com) loads the default webpage from that particular website. Output: Google. If we wanted to load a specific webpage from a particular website, you can add the specific webpage after the domain name; see table 1 for some examples.
|Code||<a href="http://www.scriptingmaster.com/site-map.htm">Site Map</a>|
|Description||Loads the site map of ScriptingMaster.com's website. The file site-map.htm is listed after the domain name and forward slash.|
|Code||<a href="http://www.scriptingmaster.com/scripting-tools/scripting-tools.asp">Scripting Tools</a>|
|Description||In this example, we use the folder name "scripting-tools" after the domain name. Then, we use the forward slash and list the specific web page: scripting-tools.asp.|