URLs

URLs are meant to specify the locations of resources in files on any computer in the world, so they can be a little complex. Fortunately, most of it is straightforward and familiar to you. Suppose we have a URL like:

http://cs.wellesley.edu/~cs110/lectures/L03-html/index.html
PROTOCOL://SERVER.DOMAIN/PATH/FILE

Let's break it down:

Because URLs can specify files on many different kinds of computers, you should stick to a lowest common denominator when naming your directories and files, to avoid confusing machines and browsers. The lowest common denominator means:

Furthermore, be careful with upper and lower case. To your eyes, cats.html and Cats.html may seem like the same filename, but to a computer, they're as different as cats.html and dogs.html. The same rule is true of directory names: they are case-sensitive. Many people like to stick to all lower-case, just so they don't have to remember.

Exercise 1

Use a file transfer program (such as Fetch or WinSCP) to create a path of directories in your CS account, and then create a simple web page that just says “hello world” and put it in the bottommost directory. Finally, put in a link to that “hello world” page in little.html.

The Tree Directories

Today, most operating systems (including Unix, Macs, and Windows), organize the contents of a computer's hard drive in directories (AKA folders). Directories and files form a "tree" structure, because of the ability of directories to contain other directories. Here's a made-up example, for a web site about Joss Whedon:

A sideways treeA tree of folders
a sideways tree a tree of folders

What we're trying to show here is the kind of listing you might get from either the Windows Explorer or the Macintosh finder, where the contents of a directory are indented underneath the directory. Here, we've drawn a solid vertical line to indicate the extent of the directory. A short horizontal line connects a directory to the directory it's in.

For example, we can see that "buffy.html" and "willow.html" are both files in the same directory, the one called "cast," which is, in turn, one of three things in the directory called "Buffy," which is in the directory called "Joss." Joss contains two directories (Buffy and Angel) and a file called "comics.html"; and so on. Take a minute to be sure you understand the relationships among the directories and files.

Relative URLs

We can use these relationships to form a shorthand way of specifying a URL. This is called a relative URL, because we specify the location of a file relative to a known file. Here are the basic rules:

Exercise 2

Create some additional directories in your CS account and practice with the relative URLs. Relative URLs will make your lives much easier when you produce different versions and when you deliver your web site to your client. Try the equivalent of:

For Next Time

We'd like you to start thinking about web design: how the pages of a site are laid out, the color and font choices, how visitors navigate around the site, and issues like that. Some of this is pretty intuitive, and you probably already have some good ideas about this, so we're interested in sites that you think are well designed.

Please email your instructor and send him/her the URL of a web site that you think is well designed. If you'd like, you can say why, but that's not necessary. We'll collect these and tell the class about them.

Solutions to Exercises

© Computer Science 110 Staff
This work is licensed under a Creative Commons License
Date Modified: Thursday, 24-Jan-2008 12:16:13 EST