6.1 Linking to Websites

For computers connected via a network (such as the Internet) it is no more difficult for a computer to open files on another computer as it is for those sitting on its own drives. As mentioned earlier, the anchor tag <a> and the href attribute are used in tandem to make links, and also with the span class="att">title attribute to add additional information. To make links to another website, rather than files on our own PC, the format is much the same. For example:

<a href="http://www.freewebtutorial.co.uk/" title="FREE WEB TUTORIAL">
Free Web Tutorial</a>

This would look like this in a browser:

The only difference here is the value of the href attribute. It has been given the value "http://www.freewebtutorial.co.uk", which is a full web address called a URL (Uniform Resource Locator). Note that the "http://" must always be included in URLs. Again the content text between the opening and closing tags, Free Web Tutorial, is shown in the browser as the link that can be clicked upon.

By default, links open web pages in the same browser window. In other words, when you click a link you will leave the current web page and land on another, which may be in a different website altogether. Sometimes you may wish to open a new page but retain the page you are on. To force a link to open a web page in a new window, the target attribute can be used with the value "_blank". For example:

<a href="http://www.freewebtutorial.co.uk/" title="FREE WEB TUTORIAL"
target="_blank">Free Web Tutorial</a>

As a courtesy it is sometimes wise to inform visitors that a link will open in a new page.