Got all that? Yeah, I know-it's as clear as mud. Well, have no fear. If you can keep the how, who, where, and what idea in your head, it'll all sink in eventually. Getting Hyper: Creating Links in HTMLOkay, with that drivel out of the way, it's time to put your newfound know-how to work (assuming, that is, I haven't scarred you for life!). To wit, this section shows you how to use HTML to add hypertext links to your Web page. The HTML tags that do the link thing are <A> and </A>. (Why "A"? Well, as you'll find out later on-see the section "Anchors Aweigh: Internal Links"-you can create special links called anchors that send your readers to other parts of the same document, instead of to a different document.) The <A> tag is a little different from the other tags you've seen (you just knew it would be). Specifically, you don't use it by itself but, instead, you shoehorn into it the URL of your link. Here's how it works: <A HREF="URL"> Here, HREF stands for Hypertext REFerence. Just replace URL with the actual URL of the Web page you want to use for the link (and, yes, you have to enclose the address in quotation marks). Here's an example: <A HREF="http://www.logophilia.com/Home/homepage.html"> Now you can see why I made you suffer through all that URL poppycock earlier: it's crucial for getting the <A> tag to work properly. You're not done yet, though; not by a long shot (insert groan of disappointment here). What are you missing? Right, you have to give the reader some descriptive link text on which to click. Happily, that's easier done than said because all you do is insert the text between the <A> and </A> tags, like so: <A HREF="URL">Link text goes here</A> Need an example? You got it (see the file LINK2.HTM on the disk): Why not head to my <A HREF="http://www.logophilia.com/Home/homepage.html">home page</A>? Here's how it looks in a Web browser. Notice how the browser highlights and underlines the link text and when I point my mouse at the link, the URL I specified appears in the status bar. Hypertext links are generally divided into two categories: external and internal. An external link is one that sends the person who clicks it to a different document. You have two choices here: you can link to a Web page in a different directory or on a different system (I call this a "faraway" link), or you can link to a Web page in the same directory as the current page (I call this a "nearby" link). An internal link (an anchor) sends the reader to a different part of the same document. The next few sections describe each type of link. External Links to Faraway PagesThe most common type of link is one that whisks the reader off to a page at some other Web site. Many Webmeisters use these kinds of external links to provide their readers with a quick method of surfing to related sites. For example, if you're putting together a page extolling the virtues of, say, the Helsinki Formula, you may want to include some links to pages about Helsinki or Finland or even The Man From U.N.C.L.E. For these types of links, make sure your <A> tag includes the full address of the new location, as described in the preceding section. Lots of pages also include links that point to the author's fave rave Web
sites and to those sites that the author deems "cool." These so-called "hot
lists" are a popular item on home pages, and they can be fun for surfers
(providing, of course, they share the Web page creator's taste in what's cool).
External Links to Nearby PagesWhen putting together Web pages, the operating principle is "Bet you can't create just one!" That is, people usually get so juiced by getting a page on the Web that they're inspired to do it once more from the top. It's not at all unusual for a prolific Websmith to have five, ten, or even 20 different pages! Chances are that if you create more than one Web page at least a few of your pages will be related, so you'll probably want to include links that take your readers to other examples of your Web handiwork. You'll probably store all your Web pages in the same directory, so the how, who, and where parts of the URL will be the same as the current document. For example, compare the URL of my home page with the URL of another HTML file I use called guestbook.html: http://www.logophilia.com/Home/homepage.html http://www.logophilia.com/Home/guestbook.html As you can see, the two addresses are identical right up to (but not including) the filenames. This is good because if I want to include a link to guestbook.html in my home page, I only have to include the filename in the <A> tag. That's right: if you're creating a link to a document in the same directory, you can simply lop off the how, who, and where parts of the URL. Here's how such a link looks: Please sign my <A HREF="guestbook.html">Guest Book</A> Anchors Aweigh: Internal LinksMost of your HTML pages will probably be short and sweet, and the Web surfers who drop by will have no trouble navigating their way around. But if, like me, you suffer from a bad case of terminal verbosity combined with bouts of extreme longwindedness, you'll end up with Web pages that are lengthy, to say the least. Rather than force your readers to scroll through your tome-like creations, you can set up links to various sections of the document. You can then assemble these links at the top of the page to form a sort of "hypertable of contents." Unlike the links you've looked at so far, internal links don't connect to a different document. Instead, they link to a special version of the <A> tag-called an anchor-that you've inserted somewhere in the same document. To understand how anchors work, think of how you might mark a spot in a book you're reading. You might dog-ear the page, attach a Post-It note, or place something between the pages such as a bookmark or your cat's tail. An anchor performs the same function: it "marks" a particular spot in a Web page, and you can then use a regular <A> tag to link to that spot. I think an example is in order. Suppose I want to create a hypertext version of this chapter. (As a matter of fact, I did! Look for the file named CHAPTER7.HTM on the disk.) To make it easy to navigate, I want to include a table of contents at the top of the page that includes links to all the section headings. My first chore is to add anchor tags to each heading. Here's the general format for an anchor: <A NAME="Name">Anchor text goes here</A> As you can see, an anchor tag looks a lot like a regular hypertext link tag. The only difference is that the HREF part is replaced by NAME="Name"; Name is the name you want to give the anchor. You can use whatever you like for the name, but most people choose relatively short names to save typing. For example, this chapter's first section is titled "The URL of Net: A Cyberspace Address Primer." If I want to give this section the uninspired name Section1, I use the following anchor: <A NAME="Section1">The URL of Net: A Cyberspace Address Primer</A> Now, when I set up my table of contents, I can create a link to this section by using a regular <A> tag (with the HREF thing) that points to the section's name. And, just so a Web browser doesn't confuse the anchor name with the name of another document, I preface the anchor name with a number sign (#). Here's how it looks: <A HREF="#Section1">The URL of Net: A Cyberspace Address Primer</A> Just so you get the big picture, here's an excerpt from the HTML file for this chapter (the figure shows how it looks in a browser):
Creating an E-Mail LinkAs I mentioned earlier, there's no reason a link has to lead to a Web page. In fact, all you have to do is alter the "how" part of a URL, and you can connect to most other Internet services, including FTP and UseNet. In this section, however, I'll concentrate on the most common type of non-Web link: e-mail. In this case, someone clicking on an e-mail link will be presented with a screen (assuming their browser supports this kind of link, which most recent browsers do) they can use to send a message to your e-mail address. Now that's interactive! This type of link is called a mailto link because you include the word mailto in the <A> tag. Here's the general form: <A HREF="mailto:YourEmailAddress">The link text goes here</A> Here, YourEmailAddress is your Internet e-mail address. For example,
suppose I want You can write to me at my <A HREF="mailto:paul@mcfedries.com">e-mail address.</A> The next figure shows how it looks in NSCA Mosaic.
The Least You Need to KnowThis chapter gave you the lowdown on using HTML to include hypertext links in your Web pages. Here's a review of today's top stories:
|
|||||||||||||||||||||||||||||