The parts of a URL

The hostname part of the URL should be a valid Internet hostname such as or It can also be an IP address such as or

The port number is optional. It's not necessary if the service is running on the default port, 80 for http servers.

The path points to a particular directory on the specified server. The path is relative to the document root of the server, not necessarily to the root of the file system on the server. In general a server does not show its entire file system to clients. Indeed it may not really expose a file system at all. (Amazon's URLs, for example, mostly point into a database.) Rather it shows only the contents of a specified directory. This directory is called the server root, and all paths and filenames are relative to it. Thus on a Unix workstation all files that are available to the public might be in /var/public/html, but to somebody connecting from a remote machine this directory looks like the root of the file system.

The filename points to a particular file in the directory specified by the path. It is often omitted in which case it is left to the server's discretion what file, if any, to send. Many servers will send an index file for that directory, often called index.html. Others will send a list of the files in the directory. Others may send an error message.

The fragment identifier is used to reference a named anchor or ID in an HTML document. A named anchor is created in HTML document with an A element with a NAME attribute like this one:

<A NAME="xtocid1902914">Comments</A>

A URL that points to this name, includes not only the filename, but also the named anchor separated from the rest of the URL by a # like this

In more modern browsers we can also use an ID attribute on any element instead:

<p id="xtocid1902914">Comments</p>

For more detailed information about URLs, see

Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998, 2002, 2003 Elliotte Rusty Harold
Last Modified July 1, 2005