|
Virginia's HTML—Hyperlinks |
You've been clicking happily from one page to the next in this tutorial, probably without giving it much thought. In a well-designed website it's easy to get around. If the website needs navigation instructions, it probably needs to be redesigned. These links are examples of hyperlinks within a single site.
You can also have links to other sites and, if you have long pages, you can have links to specific locations within a page. I'll show you all three types here, although I'll not spend much time on the links within a page since I don't normally use them.
|
|
|
You should now have four files.
| <A HREF="subdir1/subdir1-page.html">go to subdir1</A> |
The HREF attribute within a website is the relative address (relative to the current page) of the page you want to view.
| To Navigate From | Use this path/name |
|---|---|
| root to another root page | root-page.html |
| root to subdir1 | subdir1/subdir1-page.html |
| subdir to root | ../root-page.html or ../virginia.html |
| subdir1 to subdir2 | ../subdir2/subdir2-page.html |
To lock this firmly into your brain, add links from each page to each of the other pages. I'll get you started with links from virginia.html to each of the other pages.
| within the <BODY> of virginia.html |
|---|
|
<A HREF="root-page.html">root-page</A><BR> <A HREF="subdir1/subdir1-page.html">subdir1-page</A><BR> <A HREF="subdir2/subdir2-page.html">subdir2-page</A> |
I've used <BR> tags to separate my links. You could also put your links between the <LI> and </LI> tags in an ordered or unordered list. Or you could move them to the right border by putting them inside <P ALIGN="right"> and </P> tags. You can also use <B> and <I> tags between the <A> and </A> tags. Have some fun!
| <A HREF="http://www.MartinRinehart.com">Martin Rinehart's site</A> |
Suppose that the second site is one that your visitor will visit briefly (for example, to double check a fact) before continuing in your site. You can pop up the second site in a new browser window, this way.
| <A HREF="http://www.MartinRinehart.com" TARGET="_new">Martin Rinehart's site</A> |
For an example, check the cross reference links in my fitness site.
Users with a lame old browser (MSIE) will get a new browser popping up with TARGET="_new". Users with a tabbed browser (Firefox, Konqueror, Netscape, Opera) will get either a new browser or a new tab depending on the way they've configured their browser.
| <A NAME="topic-a"> |
To link to this anchor from within the page, use this syntax.
| <A HREF="#topic-a">view Topic A</A> |
To link to this spot from another page in your site, use this syntax.
| <A HREF="relative/path/filename.html#topic-a">view Topic A</A> |
To link to this spot from another website, use this syntax.
| <A HREF="http://www.SomeOtherSite.com/relative/path/filename.html#topic-a">view Topic A</A> |
So have some fun linking. Tomorrow I'll show you the basics of tables. (All the boxes you see above are tables. Some are tables inside other tables.) If you become a tablemeister you'll really be HTML-enabled.