|
A
Target or sometimes called an anchor is a placeholder
within an HTML document that may be used for
linking. Rather than link to another document,
you are simply creating a link within the same
document.
Defining
a target is quite simple. Instead of using the
<A HREF> tag, you use a different parameter
in the <A> tag so that the tag is a name
tag (i.e. <A NAME=" ">) - Take
the following example where a target is defined
as being "target":
After Defining the target, you can then link
to that target. The following shows the code
that links to the target we just defined:
|
<a
HREF="#target">This
is the text that is the link</a>
<a NAME="target"></a> |
Notice the <a HREF> tag has a pound sign
(i.e. #) before the name of the target
It
tells the browser to look for a target rather
than a URL
Let's
get creative. Let's say in Document A you want
to create a link to a target that resides in
Document B. The URL for Document B is http://yourdomain.com/index.php
- within Document B is the following tag about
5 screens down on the page
In Document A, you create a link to that Target
(anchor) by adding the following line:
|
<a
HREF="http://yourdomain.com/index.php#target">Click
here to go there</a> |
Notice you simply appended the #target onto
the end of the URL. This tells the browser to
first retrieve the document found at http://yourdomain.com/index.php
and then after retrieving the document position
the document to the target (anchor) #target
|