- Linking to Other Web Pages
- Linking Between Your Own Pages
- Relative Addresses
- Summary
- Q&A
- Workshop
Relative Addresses
If you have many pages, you'll want to put them in more than one directory folder. In that case, you still shouldn't use the full Internet address to link between them. You can use relative addresses, which include only enough information to find one page from another.
A relative address describes the path from one Web page to another, instead of a full (or absolute) Internet address.
For instance, suppose that you are creating a page named zoo.htm in a directory folder named webpages on your hard drive. You want to include a link to a page named african.htm, which is in a subfolder named elephants within webpages. The link would look like the following:
<a href="elephants/african.htm">learn about african elephants.</a>
Caution - The / forward slash is always used to separate directory folders in HTML. Don't use the \ backslash normally used in Windows and DOS!
The african.htm page might contain a link back to the main zoo.htm page:
<a href="../zoo.htm">return to the zoo.</a>
The double dot (..) is a special code that indicates the folder containing the current folder. (The .. means the same thing in DOS, Windows, Macintosh, and UNIX.)
You can then move these pages to another directory folder, disk drive, or Web server without changing the links, as long as you always put african.htm inside a subfolder named elephants.
Relative addresses can span quite complex directory structures if necessary; Hour 21, "Organizing and Managing a Web Site," offers more detailed advice for organizing and linking among large numbers of Web pages.
To Do
You probably created a page or two of your own while working through Hour 2, "Create a Web Page Right Now." Now is a great time to add a few more pages and link them together:
-
Use a home page as a main entrance and central hub to which all your other pages are connected. If you created a page about yourself or your business in Hour 2, use that as your home page. You also might like to make a new page now for this purpose.
-
On the home page, put a list of <a href> links to the other HTML files you've created (or plan to create soon). Be sure that the exact spelling of the filename, including any capitalization, is correct in every link.
-
On every other page, include a link at the bottom (or top) leading back to your home page. That makes it simple and easy to navigate around your site.
-
You might also want to include a list of links to sites on the Internet, either on your home page or a separate hotlist page. People often include a list of their friends' personal pages on their own home page. (Businesses, however, should be careful not to lead potential customers away to other sites too quicklythere's no guarantee they'll come back!)
Remember to use only filenames (or relative addressing) for links between your own pages, but full Internet addresses for links to other sites.
Note - There is one good reason to sometimes use the complete address of your own pages in links. If someone saves one of your pages on his or her own hard drive, none of the links to your other pages from that page will work unless they include full Internet addresses.
I like to include a link with the full address of my main home page at the bottom of every page, and use simple filenames or relative addresses in all the rest of the links.