- So how do you create a link that points to a location inside of a
document?
- Just as we did when we were creating links to another web page, we
will use the anchor tag with an HREF attribute. However, rather than
setting the HREF value to a simple URL, we will define a location
within a page to link to.
- An "internal anchor" uses a number sign and an internal page
keyword to define a location. It looks something like this...
<A HREF = "#top">Go to the top of this page</A>
- Of course, how does the web browser know what "#top" means?
- Well, we have to let it know with HTML code. Specifically, we will
provide an anchor to link to by using the NAME attribute in the
anchor tag.
- The NAME attribute specifies a location within a page. Thus, for
example, if we wanted the internal anchor in the previous example to
work, we would need to put the following anchor at the actual top of
the document with the internal link:
<A NAME = "top"></A>
- Try it out, by clicking here. We have
included the example code in this very document.
- Of course, you are not limited to linking from one part of a page
to another. You can also link to a part of another page by including a
URL within the HREF attribute. For example, the following anchor tag
would link to the bottom of the page at
http://www.extropia.com/index.html:
<A HREF = "http://www.extropia.com/index.html#bottom">
click here</A>
Previous Page |
Next Page
|