Resources and URIs
At some point in the past, someone came up with the concept of a resource. What is a resource, you ask? Everything is! This page is a resource, this sentence is a resource, you're a resource, I'm a resource, my e-mail inbox is a resource. Resources are the most general type of abstraction. A resource is just something, anything.
So, I hear you asking, what's the reason for abandoning a good old English word like "thing" and calling things resources? The reason is not quite clear, but it boils down to the fact that we need some way of accessing resources. The important characteristic of a resource, however, is that it is unique.
If you've been using the Internet for even a short while, you'll have realized that trillions of things are accessible through it. The need for a general way to refer to things has come about. For instance, when I want to refer to this Web page, I need a simple way to describe it, that can be comprehended by both humans and computers. And hence, some innovative people came up with Uniform Resource Identifiers (URIs).
A URI identifies a resource (which, as I pointed out, is just a fancy word for "thing"). There are two kinds of URIs: URNs, or Uniform Resource Names and URLs, or Uniform Resource Locators. Confused yet? You should be. I'm going to cover a few basics on URI syntax. If you get too confused, don't worry, it'll become clearer in the next section where I give some examples and show URIs in action.
There are basically two kinds of resources (things). Some are unique, but might have many instances. For instance, Shakespeare's Hamlet is a unique resource, as in it is a single body of text. Hamlet, act V, scene I, lines 2-15, is still a unique piece of text. It is the same piece of text no matter where we find it: in a book, a voice recording, a CD-ROM, the videotape of a stage production, even the Mel Gibson movie (albeit with more cheese added). A URN points to such a resource; it doesn't tell us where to find it, but it does uniquely identify a resource.
The other kind of resource is something that is unique in that it has a unique location where it can be found. This Web page is an example. It resides on WebReference.com's Web server, in the Experts section, in the HTML with Style area, in the first page of the second tutorial. It could also be published in a book, or recited, or be printed out and stacked on your desk, but these instances would be different. This is the kind of resource identified by a URL. A URL will tell us where a resource is located. It's a lot like a postal address - in fact, postal addresses can be expressed as URLs.
So a URI is a way of identifying something. As you might have guessed, both URNs and URLs are very useful for different purposes. Unfortunately, at the time this document is being written, URNs are still new technology and are not well defined. Most HTML user agents definitely do not supported by them. So, in this tutorial, we will concentrate on URLs.
URLs have a certain defined syntax that is beyond the scope of this tutorial. If I were to tell you everything about the rules of how to write URLs, I'd be going on all day. Instead, I'll cover only the types of URLs that you're most likely to use in your Web pages. If practice changes on this topic and people start using a new type of URL or URI, watch this space closely as I'll update the tutorial to reflect it.
The only general rule I'm going to mention about URLs is that they
can be broken down into three parts: the scheme name, a
:), and the location itself. Here are some examples:
In the above examples, the scheme names are
mailto. They are followed by a colon and a bunch of
characters that is the main body of the URI. The scheme defines the way
the rest of the URI is interpreted. For example, take the two URLs
These point to different locations, because although they have the
same syntax after the colon, they have different schemes, and so are
interpreted differently. The text
has different meaning in the
http URL scheme than it does
ftp URL scheme.
You may have noticed that some URL schemes use a series of
words separated by slash characters (
/). These fall under
the heading of generic URLs. Everything else is an
opaque URL. The
http scheme, for instance,
defines generic URLs. The
mailto scheme, on the other hand,
defines opaque URLs. The reason we make this distinction is that it is
possible to have relative URLs when the scheme we are using
creates generic URLs. We'll cover relative URLs later on, so keep that
I know you're probably confused by now, so here's a breakdown of what we've covered on URIs:
- URIs identify unique resources.
- There are two types of URIs: URNs and URLs. URNs are not in wide use yet.
- The way a URL is interpreted is not defined by URL syntax, but by using a certain URL scheme.
- Some URL schemes define opaque URLs, others define generic URLs.
- Schemes that define generic URLs can facilitate the use of relative URLs.
Now let's see all of that in action as we look at the http URL scheme