Creating HTML links

A link between pages is called an anchor. You can think of anchors as ``active footnotes.''

Anchors (which appear as blue, red, or otherwise highlighted text) are the real innovation of the Web. They can point to any type of document, on any computer in the world. Some examples of what anchors can point to are:
  • Plain text documents
  • HyperText pages
  • Animations (typically in MPEG format)
  • Compressed tar files
  • TIFF images
  • Another location in the same file
  • Most anchors consist of a URL, descriptive text or imagery, and an optional name.

    	<a href="url"> descriptive text </a>
    	<a name="string"> descriptive text </a>
    	<a name="string" href="url"> descriptive text </a>
    
    The name parameter is useful if you have a long document, and want to jump directly to someplace other than the top.

    Here's another location!!!!

    You specify a location by appending a pound sign (#) followed by the name string after the URL, e.g.:
    	/afs/cs/project/vision/www/talk/links.html#another
    

    It pays to be clever with URLs when writing HTML documents

    It's good to remember that not everybody will be accessing your pages through a server. WWW client programs are smart enough to use the local filesystem, if you use the correct abbreviation. The following all point to the same information: Advertizing to the world: http://www.cs.cmu.edu/afs/cs/usr/sas/www/home.html

    Someone offsite with afs access: /afs/cs.cmu.edu/usr/sas/www/home.html

    Another file in the same directory: home.html

    You could use any of these three URLs when you create a document, but the best one to use is the shortest one (relative pathname). That way you don't force everybody to use the server when they read your data, it's easier to move files around if you decide to reorganize, and you keep the load low on the server that outside people must use; everybody's happy.
    Carnegie Mellon Computer Science mwm@cs.cmu.edu
    Next, Up, Prev,