Thursday, September 15, 2016

Part 4 - Hyperlinks and Bookmarks


Introduction

You should know how what a hyperlink is and what it is used for. If you do not, a hyperlink is a piece of text you click to be taken to another page. A bookmark is a way of bookmarking a point on your page so that you can hyperlink to it.

The <a> Tag

The <a> tag is used when creating hyperlinks and bookmarks. It stands for anchor. The functions are explained more fully below.

<a href>

To create a hyperlink you need to use the href variable of the <a> tag. Href stands for Hyperlink REFerence. To make a piece of text or an image into a hyperlink you contain it in:

<a href="pageurlhere">Text Goes In Here</a>

Hyperlinks can specify several things:
Function
Example Code

Web Page or Site
<a href="http://www.webaddress.com/folder/page">
Local Page
<a href="pagename.html">
Local Page In A Folder Level Below
<a href="foldername/pagename.html">
Local Page In A Folder Level Above
<a href="../pagename.html">
Open E-mail Program With E-mail Addressed
<a href="mailto:yourname@yourname.com">
Bookmarked Section
<a href="#bookmarkname">
Bookmarked Section In Another Page
<a href="pagelocation.htm#bookmarkname">



Bookmarks

Bookmarks on a page are very easy to make as they also use the <a> tag. Instead of changing the href variable you use the name variable. For example:

<a name="top">The First Text In The Page</a>

Will create a bookmark called top in the text which the tag surrounds. An image can also be contained in this tag. You can then link to this using a standard hyperlink:

<a href="#top">Back To Top</a>

You can name bookmarks anything you like. Bookmarks are very useful on pages which are very long as they can be used to quickly go to another part of the page.

No comments:

Post a Comment