HTML and CSS Reference
Q: It seems like there are two ways
to link to pages now: relative paths
A: Relative paths can only be used
to link to pages within the same website,
while URLs are typically used to link to
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
A: Yes; good catch. The file protocol
is used when the browser is reading files
right off your computer. For example,
the file URL, “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 and browser.
At Caffeine Buzz, we use
relative links to other pages on
our site, and URLs to link offsite, like
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 website
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
index.html. Why is there a “:8000” in
A: The “:8000” is an optional “port”
that you can put in an HTTP URL. Think
of a port like this: the website 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.
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.