MMDT1021 Chapter 6 Notes - page 2

Creating Anchors

Code Page
A page with the following Anchors: <a name="ABBR"></a> <a name="ACRONYM"></a> <a name="ADDRESS"></a> <a name="CITE"></a> <a name="CODE"></a> <a name="DEL"></a> <a name="DFN"></a> <a name="EM"></a> <a name="INS"></a> <a name="KBD"></a> <a name="Q"></a> <a name="SAMP"></a> <a name="STRIKE"></a> <a name="STRONG"></a> <a name="VAR"></a> <a name="B"></a> <a name="BIG"></a> <a name="BLINK"></a> <a name="FONT"></a> <a name="I"></a> <a name="SMALL"></a> <a name="SUB"></a> <a name="SUP"></a> <a name="TT"></a> <a name="U"></a> Result
Source
Note:  Some browsers seem to be buggy in respects to the anchor.  I found that for an Anchor to work all the time, there must be some text of some sorts between the opening "a" tag and the closing "a" tag.  Example: <a name="ANCHORNAME">Some Text</a>

If you don't want any text to show, then do something like this:
<a name="ANCHORNAME">&nbsp;</a>
The &nbsp; is a non-breaking space and is a good invisible text marker.


Update: The new HTML5 way of doing anchors is to use the attribute "id" rather than "name". So setting an anchor is just:

<p id="top">Top of page</p>

Then to link to that anchor, is just like before:

Go to<a href="#top">top</a> of page.

Example of an anchor in a really long page.

Linking to a Specific Anchor

Code Page
<a href="../htmlnotes/formatting/CharacterFormatting.htm#code">CODE</a> CODE
 
Code Page
<a href="../htmlnotes/formatting/CharacterFormatting.htm#blink">BLINK</a> BLINK
 
Targeting Links to Specific Windows
    Special Target Names
  1. TARGET="_blank" This target will cause the link to always be loaded in a new blank window or a new tab depending on the browser. This window is not named.
  2. TARGET="_parent" This target makes the link load in the immediate FRAMESET parent of this document. This defaults to acting like "_self" if the document has no parent.
  3. TARGET="_self" This target causes the link to always load in the same window where the action originated. This is useful for overriding a globally assigned BASE target.
  4. TARGET="_top" This target makes the link load in the full body of the window. This defaults to acting like "_self" if the document is already at the top. It is useful for breaking out of an arbitrarily deep FRAME nesting.
 
 
This link opens the document in a new window.
Code Result
This is some text before the link. <a href="../index.htm" target="_blank">MMDT1021 Internet and the Web</a> This is some text after the link. This is some text before the link. MMDT1021 Internet and the Web This is some text after the link.
  
Setting the Default Target

Use the <BASE TARGET="_targetname"> tag to set the default target type for all links on a page. The default target when none is set is "_self".