Web Design - Introduction to HTML: Hyperlinks

Sections:  Introduction  |  Section 1  |  Section 2  |  Section 3  |  Section 4  |  Section 5
Section Three:  Part A  |  Part B  |  Part C  |  Part D  |  Part E  |  Part F  |  Part G
The Target Attribute

The "target=" attribute

Has this ever happened to you: you are visiting a web site - clicking on various links - and then all of a sudden you click a link and it opens in a new browser window or tab? Some web designers / web authors do this so that you differentiate between pages that are associated with their web site and those pages that are outside the web site’s structure.

Extend Your Learning

Let’s return to the fictional dirt bike page discussed earlier. Imagine that instead of creating one web page about dirk bikes, you decide to create several web pages about different dirt bike brands. You intend to link all of the web pages you create together in a dirt bike web site. On your web pages, you want to have links that go to the web pages you created as well as links to web sites that you did not create. For instance, you want to include a link to the official Yamaha Motor web site on the web page you create about the Yamaha brand of dirt bikes.

After some consideration you decide that you would like all of the web pages you created to open in the same web browser – meaning the linked page replaces the current page in the web browser; but, you would like links to web sites outside your dirt bike web site to open in a new browser window. To do this, you would add the target="" attribute to the opening <a> tag.

The target="" attribute has a variety of values that can be associated to it, but the one that will create the desired effect of opening a new browser window when the link is clicked is target="_blank" – do not forget to include the underscore _. The image below show how you could add the target="" attribute to your previous “I love Yamaha” link so that when a visitor to your site clicks the link, the official Yamaha Motor web site would open in a new browser window.

yamaha link

NextNext

© 2008 KCDL. All rights reserved.