96
getting connected
you are here
�
147
there are no
Dumb Questions
Q:
It seems like there are two ways
to link to pages now: relative paths and
URLs.
A:
Well, relative paths can only be
used to link to pages
within
the same Web
site, while URLs are typically used to link
to other Web sites.
Q:
Wouldn’t it be easier if I just
stuck with URLs for links to my own
pages and outside pages? That would
work wouldn’t it?
A:
Sure, it would work, but there’s
a couple of reasons you don’t want to go
there. One problem is that URLs are hard
to manage when you have a lot of them in
a Web page: they’re long, difficult to edit,
and they make HTML more difficult to read
(for you, the page author).
Also, if you have a site with nothing but
URLs that link to local pages and you
move the site or change its name, you
have to go change all those URLs to
reflect the new location. If you use relative
paths, as long as your pages stay in the
same set of folders – because the links
are all relative – you don’t have to make
any changes to your <a> element href
attributes.
So, use relative links to link to your own
pages in the same site, and URLs to link
to pages at other sites.
Q:
Haven’t we seen one other
protocol? I kept seeing “file://” before
we started using a Web server.
A:
Yes; good catch. T
he file protocol
is used when the browser is reading files
right off your computer. The file URL,
for example, “file:///chapter4/starbuzz/
index.html”, tells the browser that the
file “index.html” is located at the path
“/chapter4/starbuzz/”. This path may look
different depending on your operating
system.
One important thing to notice in case you
try to type in a file URL is that the file URL
has three slashes, not two, like HTTP.
Remember it this way: if you take an HTTP
URL and delete the Web site name you’ll
have three slashes, too.
Q:
Are there other protocols?
A:
Yes, many browsers can support
retrieval of pages with the FTP protocol,
and there is a mail protocol that can send
data via email. HTTP is the protocol you’ll
be using most of the time.
Q:
I’ve seen URLs that look like
this: http://www.mydomain.com:8000/
index.html. Why is there a “:8000” in
there?
A:
The “:8000” is an optional “port”
that you can put in an HTTP URL. Think
of a port like this: the Web site name is
like an address, and the port is like a
mailbox number at an address (say, in an
apartment complex). Normally everything
on the Web is delivered to a default port
(which is 80), but sometimes Web servers
are configured to receive requests at a
different port (like 8000). You’ll most likely
see this on test servers. Regular Web
servers almost always accept requests
on port 80. If you don’t specify a port, it
defaults to 80.
At Caffeine Buzz we use relative
links to other pages on our site,
and URLs to link offsite, like
www.caffeineanonymous.com.