Site
Categories
 
 

HTML Anchor Tags - Lesson 3


So you want to know how to make hyperlinks in HTML? Well look no further. Hyperlinks are very important with search engines in particularly. They also add navigation to webpages. HTML uses the anchor tag (<a>) and the href attribute to address the document to link to. To apply a hyperlink, use the following:


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


The above will produce the words "Click me" in your browser. If you click these words, it will take you to Google.com, because you defined that in the href attribute. If you want the link to open Google in a seperate browser window, that is possible. You may want people to continue surfing your site, because the standard way will open Google in the current browser window, replacing your website.

To open the document in a new browser, copy the following:


<a href="http://www.google.com/"
target="_blank">Click me>


The "target="_blank" tells the browser to open the document in the new page, the rest of the code remains the same. Now you know the basics of hyperlinks, let's investigate making an image a link.

At this point, make sure you have read the tutorial on HTML Images. Now, you have your image on the page, and you want to make it clickable. If you remember from the other tutorial, you will have something like this:


<img src="http://www.google.co.uk/intl/en_uk/images/logo.gif">


To make your image clickable, you need to add an anchor tag, which we have just learnt. Add the anchor tags at the beginning and end, as follows:


<a href="http://www.google.com">
<img src="http://www.google.co.uk/intl/en_uk/images/logo.gif">
</a>

We have also defined the site, http://www.google.com. This means, when you click the image (which is located at http://www.google.co.uk/intl/en_uk/images/logo.gif, the browser will go to Google). Now you know about the anchor tag. Try these various examples for yourself, to master hyperlinks.
By
 
 
Ads