Link to USGS home page
Internal USGS Access Only

Learning HTML- Links and Comments

Hypertext Links
The A (anchor) element is used to define a link. The following example makes the word "hat" a link to a document "hat.html" in the same directory.
The cat in the <a href="hat.html">hat</a>.

The cat in the hat.

To link to a document at another Web Server, you need to use a URL (Uniform Resource Locater).
The cat in the <a href="http://www.seuss.org/hat.html">hat</a>.

Hypertext links can also link to a different place in the same document. To make this work one has to mark a place to link to:
<a name="mainCharacter">Sam I am</a>.

Text marked with a "A NAME" will not appear any different on the screen.

And then it can be linked to like this:
I do not like green eggs and ham.
I do not like them <a href="#mainCharacter">Sam I am</a>.

You can reference a specific spot in a remote document as well: <a href="http://water.usgs.gov/atlas/index.html#omb">

It is a good idea to create A NAME references for all second and third level headings.
<h3><a name="nameOfLink">A Title</a></h3>

Note: NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). Names are defined to be case sensitive, but IE does not honor this.

Links can be made to anonymous ftp, or even to email addresses:
<a href="ftp://somehost/pub">   anonymous ftp
<a href="mailto:mailid@hostname">   email

Comments
Html comments have the following format:
<!--this is a comment-->

A comment can extend for multiple lines.
<!--
  this is line one of a comment
  this is line two of a comment
-->

Although the html standard allows greater-than (>) and less-than (<) characters in a comment, it confuses many browsers and should be avoided.

Do not place a double dash -- within your comments! This will be taken by some browsers as the end of the comment, since -- is the sgml end-comment flag.

Use entity &mdash; to get a long dash: , or &ndash; to get a medium length dash: .
Entities are covered in Html Characters section.

slide 11


[up]
"Mastering a Web Site" online course
Created and maintained by Lorna Schmid and David Boldt.
http://water.usgs.gov/usgs/training/webmaster/html_links.html    
Last modified: Tue Oct 14 17:30:27 EDT 2003