QuickRead 10: Navigation
Navigation within the document
| There will be many times it's convenient to link
to another part of the same document instead of another file. For
instance, if you had a list of members (to some club) listed
alphabetically, it'd be great to provide an index on top so people can
jump to a particular bunch of names without going through the entire list.
Here's an example:
| The way to reference a different area of the current page is simple. First, you would name each area that you would like to jump to. Second, you would link to that area using the familiar <a href> tag. Use a # followed by the name of the area as the reference. If you wanted content in your document to link like this: Read about my friends John, Kathryn and Tom Stuff about John Stuff about Kathryn Stuff about Tom This is how you would code it:
<!--Linking the names John, Kathryn and Tom with
<a href> tags using a # and the name of the area as the
reference.--> <!--Naming this area: john--> <!--Naming this area: kathryn--> <!--Naming this area: tom--> . | .
| Navigation over multiple pages
| You can organize your homepage into
discrete sections (many pages instead of one). Each page resides as a separate
HTML document(file) in your public_html directory and you would link to it from
your homepage using the <a href> tag. You can link back to your
homepage from the new page using another <a href>link. Here's how:
|
To access your new page using a browser, you can type the
following in the location field:
To link to your new page from your homepage,
To link to your home page from your new page,
. | .
| Navigation over multiple
directories
| You can organize your homepage into
You may want to separate your pages into multiple directories. This is
especially useful as you begin to accumulate lots of files for your webpage.
For instance you might create a school directory with files and such related to
your school work. To do this:
|
Note, you will need to type cd .. to go up one level from the school directory to be back in the public_html directory where your main webpage resides. To access your new page using a browser, you can type the
following in the location field:
To link to your new page from your homepage,
.
| .
| Absolute, Relative and Base URL's.
| For the most part, examples in this tutorial have always used the
absolute URL to access pages. An absolute URL (Unique Resource Locator or simply the
"address") has all the information that a browser needs to find the page you are linking
to. For instance if load the following URL: | <a href=http://www.cise.ufl.edu/~gunderwo/nonex/sompage1.html>. The browser knows exactly where to find "somepage1.html" on the World Wide Web:
<a href=somepage2.html>, <a href=somepage3.html>, How would the browser know where in the World Wide Web to find those documents. The answer is that, the browser simply attaches the information (www.cise.ufl.edu/~gunderwo/nonexistent) that it received previously when it loaded somepage1.html. So as long as you are trying to access documents in the same directory that somepage1.html was in ("nonex"), you have no problem. In other words <a href=somepage2.html> is equivalent to: <a href=http://www.cise.ufl.edu/~gunderwo/nonex/somepage2.html> <a href=somepage3.html> is equivalent to: <a href=http://www.cise.ufl.edu/~gunderwo/nonex/somepage2.html
If there were subdirectories called "subdir1" and "subdir2" in the directory "nonex," they
could be accessed using just the name of the subdirectory and the name of the fil.
Using a tag called <base> the default directory that the browser should use to load all
URL's in the document can be set. The base tag goes in the document head and it
doesn't have a closing tag.
Setting the base tag to an absolute URL will make the browser resolve all URL's in the
document relative to the base URL and not the current document's URL. .
| .
| Get Behind the Wheel
| Type out the following and try some of your own stuff too:
|
<html>
<head>
<title>Fun with Navigation</title><head>
<p>Here is what we did at <a href=#stlucie>StLucie</a>,
<a
href=#phuket>Phuket</a> and <a
href=#cote>Cote D'Azur</a>: <a name=stlucie></a>
<a name=cote></a> .
| |
| Index |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |