Creating a Web Page IV: Links

0 Conversations

Please refer to previous entries in the "Creating a Web Page" series:

Ordinary links

While this tutorial doesn't assume any prior knowledge of HTML, it does assume that you've done at least a little websurfing. In that time, you've probably come across hundreds of links (sometimes called "hyperlinks"). They can be either text or an image that you click on to take you to another page. The tag for links looks kind of strange:

< A HREF="http://www.h2g2.com"> Hitchhiker’s Guide to the Galaxy < /A>

"A" stands for "anchor". You'll see later on that there are other types of tags that require an anchor. The anchors act as bookends to show how much of the text you want to be affected by the tag. In this case, it’s the words “Hitchhiker’s Guide to the Galaxy”. When you put in a link in your HTML, the browser will automatically underline it and change the color (unless the setting is changed in the preferences). Later on you'll see how to specify what color the link is changed to.

Opening a link in a new window

Making a link in a new window can be convenient- it allows people to view another site without losing yours. Note: you do actually type in the word BLANK, it's not just an example.

Sample HTML:

Here is the < A HREF="http://www.h2g2.com" TARGET="_BLANK"> H2G2 site< /A> in a new window.

Result: Here is the H2G2 site in a new window.

Targets

So far these links have taken you to other pages, either another page within your site or someone else's page. For a really long page, you can create a special kind of link called a "target" that will jump to another part of the same page. Targets come in two parts. The first part names the target, the place that the link will jump to. The target name should be short but descriptive ("top", "end", "section1", etc). The target tag goes around a word or a clump of text. For example, a target named "top" could go around the first header or even just the first word of the first paragraph. Since the anchor is just "naming" the text, marking the spot for later use, you won't see any difference in the text- the browser won't highlight it.

< A NAME="top"> Once< /A> upon a time...

To link to your target, you do something a little different: instead of saying "http://", you just type # and the name of the target:

Sample HTML:


...and they lived happily ever after.
< A HREF="#top"> Back to the top!< /A>

Click here to go back to the top of this entry

If you ever get an extensive list together, say of your favorite links, it could be handy to put in alphabetical targets. Also, if your text has several subheadings, you could create a target for each heading, then a menu at the top that would allow visitors to skip directly to a subheading instead of scrolling through everything that comes before it.

Email addresses and Usenet groups

Ever seen an email address that looked like a link? And when you click on it, it tries1 to open up a blank email message already addresses to this person? With just a slight modification of what you've just seen, you can make a link do this, too:

< A HREF="mailto:[email protected]"> Send an email to foo< /A>

Note that instead of "http://" and a web site address, you put "mailto:" and an email address. That's all there is to it!

You can also make a link to a Usenet group open up your default newsreader in a very similar fashion:

< A HREF="news:comp.infosystems.www.authoring.html"> A Usenet group for HTML questions< /A>

comp.infosystems.www.authoring.html

1"Tries" since many people never use this feature and never set up their browsers for it in the very beginning so it often just gives some sort of an error message...

Bookmark on your Personal Space


Conversations About This Entry

There are no Conversations for this Entry

Entry

A668306

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

References

External Links

Not Panicking Ltd is not responsible for the content of external internet sites

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more