Anchors
HTML 3.2 | HTML 4.0 | rfc 1738


Anchors are used to define hyperlinks. The general syntax is
   <a href="URL">click here</a>
These tags must always be paired.

There are many valid types of URLs (Universal Resource Locators)
Web Page http://www.xxx.com
http://www.xxx.com/index.html
http:page_2.html
http:../page_2.html
http://www.xxx.com/getThis.zip
File on c-drive file://c:/autoexec.bat
FTPftp://ftp.xxx.com/getThis.zip
ftp://UserName:Password@ftp.xxx.com/filename.txt
  Used when a password is required
Telnet telnet://yyy.com
telnet://UserName:Password@yyy.com
  The password remains visible in the title bar
Send E-Mail mailto:xxx@yyy.com
News Groupnews:alt.xfiles

There are numerous variations and extensions to these samples.

Notice that the reference names may contain spaces if IE 3.02 is used, but that they will fail with Netscape 3.x. Specifically, if you want portable applications, do not use spaces in any file or directory names.


Predefined Protocols

Besides http, MS Internet Explorer supports several Predefined Protocols including

This code will display a file in notepad - Anchors.htm c:/autoexec.bat
view-source is available in MS Internet Explorer 4.0 and later.

In Internet Explorer 6, this code will open a Blank Browser (alt). (In Netscape, the second example provides other data.)


Links to a Location Within a Page

Many pages have a table of contents at the top which, when clicked, will take you to a specific place in the body of the text. Various locations within a page are marked with name anchors. They are referenced by using regular href anchors (link definitions) where the name is preceded with a pound sign (#).
    <A HREF="#files">Files</A>
    <A name="files"></A>
    <a href="http://www.w3.org/TR/REC-html32.html#anchor">Anchors</a>
Of course, each name can only be used once per page.


The following will load the selected page in a separate window. If only one browser instance is open, it will start a second instance and load the page there. Otherwise, if a second instance is already running, it will load the page there and not open a third browser instance (IE 3.02).
    <a href="Anchors.htm" target="new">
    <a href="Anchors.htm" target="_blank">
New window | _blank window | Same window

The target attribute is not supported in HTML 3.2.
In HTML 4.0, target is a part of frames but new is not defined.

Using IE 3.02


<a title="Pop Up Text"></a>

The use of the optional title="string" parameter is not defined in the standards. In IE 4.72, the string contents are displayed in a small pop up box when the mouse points to the anchor. (With the mouse, point to the bold text above. The popup help displays the markup syntax using single quotes, but you must actually use double quotes. View the source to see how it is coded.)

This can be used to define acromyms like html. (Think Shakespear with olde English help.) I suggest using a unique color to indicate defined terms.

<font color=green><a title="Hypertext Markup Language">html</a></font>

This does not work in Netscape 4.05, it does work in Netscape 7.0.


Miscellaneous Examples

<A HREF="http://204.122.127.80">Back to Main</A>
<a href="http://www..."  
   OnMouseOver="window.status='Status Help String';return true;"> ... </a>
<a href="javascript:viewday(2000,10,10);">10</a>


Problems

<a href=http:fonts.htm>font</a>   Works in Netscape, fails in IE3
<a href=fonts.htm>font</a>        Works in both Netscape and IE3


The following is an example of a link from a Netscape bookmark file. Notice that additional, proprietary parameters have been added.
     <A HREF="file:///H|/Local HTML/Index.htm" ADD_DATE="868397229" 
     LAST_VISIT="870728622" LAST_MODIFIED="868397210">Click Here</A>

When you want to access a file in a shared directory which is not mapped to a drive letter, use just the name of the server without the domain name. For example,
   <a href="file://computer-ID">click here<a>
This implies that when several domains share resources, the machine names must be unique across all domains.

Display Style

I firmly believe that ALL text links should be underlined. However, there is a trend to hide this useful information and to require users to hunt for links. In IE 4.72, this can be accomplished using style sheets. If you want to leave some links underlined, you can remove the underline from specific anchors by using <a href="StyleSht.htm" style="text-decoration: none;">Style Sheets</a> Style Sheets

Remember, style sheets are browser dependent. Both examples work in IE 4.72, but neither example works in Netscape 4.05.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / HTML_Examples / Anchors.htm