A Complete Guide to Web Design

(やまだぃちぅ) #1
Simple Hypertext Links 133

Creating Links

Simple Hypertext Links

Web Design in a Nutshell, eMatter Edition

Attributes


name=text
Gives the image map a name that is then referenced within thetag.
This attribute is required.


Simple Hypertext Links


The anchor () tag is used to identify a string of text or an image that serves as
a hypertext link to another document. In its simplest incarnation, it looks like this:


I’m <A HREF="link.html">linking</A> to you!

To make an image a link, enclose the image tag within the anchor tags as follows:


<A HREF="link.html"><IMG SRC="pixie.gif"></A>

The URL is the name of the document you want to link to. URLs can be absolute
or relative.


Absolute URLs


Anabsolute URLis made up of the following components: a protocol identifier, a
host name (the name of the server machine), the pathname (if there is one), and
the specific file name. When you are linking to documents on other servers, you
need to use an absolute URL. The following is an example of a link with an abso-
lute URL:


<A HREF="http://www.littlechair.com/web/index.html">...</A>

Here the protocol is identified ashttp(the standard protocol of the Web), the host
iswww.littlechair.comandweb/index.htmlis the pathname leading to the partic-
ular file.


Relative URLs


Arelative URLprovides a pointer to another document relative to the location of
the current document. The syntax is based on relative pathname structures in the
Unix operating system, which are discussed in Chapter 4,A Beginner’s Guide to
the Server. When you are pointing to another document within your own site (on
the same server), it is usually best to use relative URLs.


For example, if I am currently in jcc.html (identified here by its absolute
pathname):


http://www.littlechair.com/web/samples/jcc.html

and I want to put a link on that page totalk.html, which is in the same directory:


http://www.littlechair.com/web/samples/talk.html

I could use a relative URL within the link as follows:


<A HREF="talk.html">...</A>

Using the same example, to link to the fileindex.htmlin a higher level directory
(web), I could use the relative pathname to that file as shown:

← Previous
Free download pdf