Links to Other Documents on the Web


So, now you have a whole set of pages on your local disk, all linked to each other. In some places in your pages, however, you want to refer to a page somewhere else on the Internetfor example, to The First Caesars page by Dr. Ellis Knox at Boise State University for more information on the early Roman emperors. You also can use the link tag to link those other pages on the Internet, which I'll call remote pages. Remote pages are contained somewhere on the Web other than the system on which you're currently working.

The HTML code you use to link pages on the Web looks exactly the same as the code you use for links between local pages. You still use the <a> tag with an HRef attribute, and you include some text to serve as the link on your Web page. Rather than a filename or a path in the HRef, however, you use the URL of that page on the Web, as Figure 5.5 shows.

Figure 5.5. Link to remote files.


Task: Exercise 5.2. Linking Your Caesar Pages to the Web

Go back to those two pages you linked together earlier today, the ones about the Caesars. The menu.html file contains several links to other local pages that provide information about 12 Roman emperors.

Now suppose that you want to add a link to the bottom of the menu file to point to The First Caesars page by Dr. Ellis Knox at Boise State University, whose URL is http://history.boisestate.edu/westciv/julio-cl/.

First, add the appropriate text for the link to your menu page, as follows:

<p><i>The First Caesars</i> page by Dr. Ellis Knox has more information on these Emperors.</p>


What if you don't know the URL of the home page for The First Caesars page (or the page to which you want to link), but you do know how to get to it by following several links on several different people's home pages? Not a problem. Use your browser to find the home page for the page to which you want to link. Figure 5.6 shows what The First Caesars page looks like in a browser.

Figure 5.6. The First Caesars page.


Note

If your system isn't connected to the Internet, you might want to connect now so that you can test links to pages stored on the Web.


You can find the URL of the page you're currently viewing in your browser in the address box at the top of the browser window. To find the URL for a page you want to link to, use your browser to go to the page, copy the URL from the address field, and paste it into the href attribute of the link tag. No typing!

After you have the URL of the page, you can construct a link tag in your menu file and paste the appropriate URL into the link, like this:

Input

<p>"<i><a href="http://history.boisestate.edu/westciv/julio-cl/"> The First Caesars</a></i>"page by Dr. Ellis Knox has more information on these Emperors.</p>


In that code I also italicized the title of the page using the <i> tag. You'll learn more about that tag and other text formatting tags in Lesson 6, "Formatting Text with HTML and CSS."

Of course, if you already know the URL of the page to which you want to link, you can just type it into the href part of the link. Keep in mind, however, that if you make a mistake, your browser won't be able to find the file on the other end. Many URLs are too complex for humans to be able to remember them; I prefer to copy and paste whenever I can to cut down on the chances of typing URLs incorrectly.

Figure 5.7 shows how the menu.html file, with the new link in it, looks when it is displayed.

Output

Figure 5.7. The First Caesars link.


Task: Exercise 5.3. Creating a Link Menu

Now that you've learned how to create lists and links, you can create a link menu. Link menus are links on your web page that are arranged in list form or in some other short, easy-to-read, and easy-to-understand format. Link menus are terrific for pages that are organized in a hierarchy, for tables of contents, or for navigation among several pages. Web pages that consist of nothing but links often organize the links in menu form.

The idea of a link menu is that you use short, descriptive terms as the links, with either no text following the link or with a further description following the link itself. Link menus look best in a bulleted or unordered list format, but you also can use glossary lists or just plain paragraphs. Link menus enable your readers to scan the list of links quickly and easily, a task that might be difficult if you bury your links in body text.

In this exercise, you'll create a web page for a set of book reviews. This page will serve as the index to the reviews, so the link menu you'll create is essentially a menu of book names.

Start with a simple page framework: a first-level heading and some basic explanatory text:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd"> <html> <head> <title>Really Honest Book Reviews</title> </head> <body> <h1>Really Honest Book Reviews</h1> <p>I read a lot of books about many different subjects. Though I'm not a book critic, and I don't do this for a living, I enjoy a really good read every now and then. Here's a list of books that I've read recently:</p>


Now add the list that will become the links, without the link tags themselves. It's always easier to start with link text and then attach actual links afterward. For this list, you'll use a tag to create a bulleted list of individual books. The <ol> tag wouldn't be appropriate because the numbers would imply that you were ranking the books in some way. Here's the HTML list of books; Figure 5.8 shows the page as it currently looks with the introduction and the list.

Input

<ul>  <li><i>The Rainbow Returns</i> by E. Smith</li>  <li><i>Seven Steps to Immeasurable Wealth</i> by R. U. Needy</li>  <li><i>The Food-Lovers Guide to Weight Loss</i> by L. Goode</li>  <li><i>The Silly Person's Guide to Seriousness</i> by M. Nott</li> </ul> </body> </html>


Output

Figure 5.8. A list of books.


Now, modify each of the list items so that they include link tags. You'll need to keep the <li> tag in there because it indicates where the list items begin. Just add the <a> tags around the text itself. Here you'll link to filenames on the local disk in the same directory as this file, with each individual file containing the review for the particular book:

<ul>  <li><a href="rainbow.html"><i>The Rainbow Returns</i> by E. Smith</a></li>  <li><a href="wealth.html"><i>Seven Steps to Immeasurable Wealth</i> by R. U.  Needy</a></li>  <li><a href="food.html"><i>The Food-Lovers Guide to Weight Loss</i> by L.  Goode</a></li>  <li><a href="silly.html"><i>The Silly Person's Guide to Seriousness</i> by M.  Nott</a></li> </ul>


The menu of books looks fine, although it's a little sparse. Your readers don't know anything about each book (although some of the book names indicate the subject matter) or whether the review is good or bad. An improvement would be to add some short explanatory text after the links to provide hints of what is on the other side of the link:

Input

<ul>  <li><a href=rainbow.html"><i>The Rainbow Returns</i> by E. Smith</a>. A"  fantasy story set in biblical times. Slow at times, but interesting.</li>  <li><a href="wealth.html"><i>Seven Steps to Immeasurable Wealth</i> by R. U.  Needy</a>. I'm still poor, but I'm happy! And that's the whole point.</li>  <li><a href="food.html"><i>The Food-Lovers Guide to Weight Loss</i> by L. Goode  </a>. At last! A diet book with recipes that taste good!</li>  <li><a href="silly.html"><i>The Silly Person's Guide to Seriousness</i> by M.  Nott</a>. Come on ... who wants to be serious?</li> </ul>


The final list looks like Figure 5.9.

Output

Figure 5.9. The final menu listing.


You'll use link menus similar to this one throughout this book.




Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day
Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)
ISBN: 0672328860
EAN: 2147483647
Year: 2007
Pages: 305

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net