5 Hypertext Links

5.1 Links

As we've mentioned, hypertext is text that contains links to other text. How do we create such a link? The answer comes in the form of the anchor tags <a>...</a>. The anchor is the "clickable" bit that takes you to the link. The "Next Page" link at the bottom of this page could be generated with the HTML:
<a href="colours.html">Next page</a>
The link is comprised of anything in between the <a> and </a>, and by default most browsers will underline it to indicate that it is a link. The attribute href means that this anchor defines a hypertext reference. Since we only specified a filename the browser will look for it in the current directory, but we can specify any URL, e.g.:
<a href="http://www.w3.org/People/Raggett/book4/ch02.html">A history of HTML</a>
which produces:
A history of HTML
Notice that we've explicitly stated that the browser should use the hypertext transfer protocol (HTTP) for this transaction. You might think this would be the default, but that is not true; if we omitted this then the browser would look for a file in the current directory called "www.w3.org/People/Raggett/book4/ch02.html" - not exactly what we wanted! If you ever need to explicitly tell a browser to look for a local file, you can state "file://" instead of "http://".

Exercise 5

Find the phrase "University of York" in your introductory paragraph, and make that a hyperlink to the University of York's home page (http://www.york.ac.uk).


Previous page Next page