Links


3.1 Linking to Other Pages

Hyperlinks are the very fiber of the world wide web. You will use these frequently in every web site you will ever create. Learn this section well! Generally, you should keep all the pages for your website together in one folder. If your pages are all in one folder, you can specify the name of the page as your link:

<a href="myotherpage.htm">My other page</a>

This will display a hyperlink to your other page:

My other page

The letter "a" signifies that you are using an anchor. Anything you put between the opening and closing anchor tags will become the hyperlink. You can also use a picture:

<a href="myotherpage.html"><img src="images/starball.jpg"></a>

images/starball.jpg

You must specify the exact path name. If the file is in a folder below the current page, you will need to use a relative pathname. (This is discussed in the File Navigation section.)

You can link to pages on the web by simply specifying the web address:

<a href="http://www.freethegnomes.com">free the gnomes home</a>

creates this link to the web: Free the Gnomes Home


3.2 sublinks

In order to point someone to a specific target on the page, you will add an id attribute to the desired element. Think of this as putting a red pushpin at a specific spot on your page. Instead of generally specifying "go to this page" you will be able to specify "go to the red pushpin on this page". You first have to create the "pushpin" (in this example inside of a <p> tag):

<p id="top">top of this page</p>

You should name the reference something that correlates to the area of the page. now that you have created the reference, you can link to it from the same page:

<a href="#top">go to the top</a>

Go to the top

or from a different page:

<a href="links.htm#top">go to the top of links page</a>

When you are linking from a different page, you specify the page name followed immediately by the name of the anchor you have created.


3.3 Site Structure

Now that you have the ability to link pages together, you should consider the ways that you might structure your site. Most web sites use a hierarchical structure. We are accustomed to navigating through files and web pages in this manner. There are several ways to facilitate navigation in your site. Regardless of how you choose to implement the navigation on your site, allow the user to move from broad to specific information. Many websites are cluttered with too much information. Furthermore it can be painfully difficult to locate the information you want in a site. Later we'll discuss frames, which give you the ability to have a static navigation pane on the side of your site which allows for easier site navigation.


3.4 Other Links

A hyperlink can refer to many types of files:

Link Type Format Description Example
FTP ftp:// Link to an ftp site ftp planet ftp site
Usenet news:alt.pathname Link to a discussion forum alt.autos.classic-trucks
E-mail mailto:somebody@somewhere Opens a new e-mail to specified address Send mail to somebody
Telnet telnet://sitenamehere Opens a dos telnet session Library of Congress

XHTML 1.0 compliant