HyperlinksThe whole point of hypertext documents, and what makes web pages so different from text documents, is the ability to create links between documents. These "hyperlinks" enable users to follow their own "path of interest" through a linked series of documents. A well designed web site will take this into account, and will offer the user various routes around the information contained in the web site. Hyperlinks can be used to jump to the start of an entirely different document, or to jump to a specific location within a document. Linking to other documentsAgain, open a new file in your text editor, and type (or copy and paste) the code from FILE6.HTML in Appendix A. Save this file as "file6.html", and open this file in your browser. A graphical browser will show something like this: Typically, text which is a hyperlink will be shown in a different colour to the rest of the text, and is usually underlined. Most graphical browsers will change the shape of the cursor when it is positioned over a hyperlink. A speech browser might handle the sentence containing the hyperlink like this: Link: This link [pause] will take you to an illustration of how lists can be used in HTML. Looking at the file we just created, you can see that the text "This link" is enclosed within two HTML tags. Immediately before the text is: <a href="file3.html">
And immediately after the text is: </a>
"A" is the "anchor" element. "HREF" is an attribute which gives the web address to which the anchor text is linked - in this case the file "file3.html". The text between the opening and closing "A" tags is the "anchor". If you click on, or otherwise select, the anchor text, you will "jump" to the start of the document referred to by the "HREF" attribute. The contents of the HREF attribute can take various forms, depending on where the link should go. In this case, it points to a file in the same directory as the file containing the link, so nothing more than the file name is required. If I wanted a link to point to a file in a sub-directory of the current directory, I would use "directoryname/filename.html" in the HREF attribute. If, in order to find the file I want the link to point to, the browser will have to move "up" to the parent directory and then down into a different sub-directory, the contents of the HREF attribute would look something like "../directoryname/filename.html", where "../" means "go up one directory level". If I was working with many levels of nested directories, I might need to use several of these at the start of the file address, eg "../../../directoryname/filename.html" (which would mean "go up three directory levels then look for the file 'filename.html' in the directory called 'directoryname'"). And finally, if I want the link to point to a file in a completely different website, the contents of the HREF attribute would be like what I type in when I want to go to a new page in my browser, eg "http://www.website.com/directoryname/filename.html". Linking to a location within a documentIt is also possible to link to a specific location within a document. This is useful if you create a long document. Instead of the user having to scroll or read through a large portion of the document to reach a specific section, you can include a menu of hyperlinks at the start of the document, each of which will take the user to the specified section of the document. Alternatively, you might have the menu of hyperlinks in one document, each one pointing to a specific section in another document. OK, time to see how this works. Open a new document in your text editor, and type (or copy and paste) the code from FILE7.HTML in Appendix A. Save this file as "file7.html". Opening another new file in your text editor, type (or copy and paste) the code from FILE8.HTML in Appendix A. Save this file as "file8.html". Open the file "file7.html" in your browser. In graphical browsers, it should look something like this: If you select the hyperlink "Go to section A", you should see this: If however, you select the link that says "Go to section C", you should see: As you will see if you look at the code in file7.html and file8.html, the positions to which we have linked are marked using a different form of the ANCHOR element, this time using the NAME attribute. <a name="bookmarkname">[text or graphic to which we want to be able to jump]</a>
The value of the NAME attribute is a "bookmark", to which we can refer in the HREF attribute of a link.
A couple of notes on links and bookmarks
|
|
http://www.users.zetnet.co.uk/dms/htmlguide/html5.html
© 1998-2001 Donna Smillie <dms@zetnet.co.uk>