Linking to files on the World Wide Web

Linking to files on the World Wide Web (web) requires the use of the full URL (or absolute URL). The full URL includes the protocol, domain name, directory name (if any), and the file name to which the link is made. All of this information helps the browser to find the destination file.

It is a good practice to check that the destination file is available as it may be on a website that you are not responsible for maintaining. If the destination file is moved, deleted, or renamed, the link to that will file no longer will work because your link path will contain outdate link information. When a user requests a file that no longer exists or perhaps because of invalid link path information, the web server will return the familiar 404-file not found response.

Constructing links to files on the web is a very straight-forward process. If you can visit a website, you are likely to be able to create a link to that website. Let's look at the steps involved in creating a link:

Steps XHTML markup
1) Start by opening an anchor tag <a>
2) Insert the href attribute <a href="">
3) Specify the URL of the destination file or website inside double quotation marks <a href="http://www.google.com">
4) Specify text or graphic that will be used to activate the link <a href="http://www.google.com">Google
5) Close the anchor tag </a>

These steps results in the following markup:

<a href="http://www.google.com">Google</a>

This shows the output of our markup:

Figure 1 shows the two servers involved in making this link possible.

Figure 1 shows that the originating file (where the link is placed) is on www.scriptingmaster.com and the destination file (to which the link is pointing) is on www.google.com
Figure 1 shows that the originating file (where the link is placed) is on www.scriptingmaster.com and the destination file (to which the link is pointing) is on www.google.com.

The five steps outlined above will help you link to any file found on the internet. Interestingly, out of the steps mentioned, the only information that will change from one link to another is the value you specify for step 2 and 4. The other syntax of the markup will remain the same regardless of the destination file or website to which you want to link. So if you wanted to link to msn.com instead of Google, your anchor markup will change to:

<a href="http://www.msn.com">MSN</a>