The World Wide Web is a network of information resources. The Web relies on three mechanisms to make these resources readily available to the widest possible audience:
HTML documents utilize URLs for specifying hypertext links. The following provides a brief introduction to URLs.
Every resource available on the Web --- HTML document, image, video clip, program, etc. --- has an address that may be encoded by a Uniform Resource Locator, or "URL" (defined in [RFC1738]).
URLs typically consist of three pieces:
Consider the URL that designates the current HTML specification:
This URL may be read as follows: Use the HTTP protocol (see [RFC2068]) to transfer the data residing on the machine www.w3.org in the file "/TR/WD-html4/cover.html". Other schemes you may see in HTML documents include "mailto" for email and "ftp" for FTP.
URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive.
The character set of URLs that appear in HTML is specified in [RFC1738].
Some URLs refer to a location within a resource. As specified in [RFC1808], this kind of URL ends with "#" followed by an anchor identifier (called the "fragment identifier"). For instance, here is a URL pointing to an anchor named section_2:
A relative URL (defined in [RFC1808]) doesn't contain any protocol or machine information. Its path generally refers to a resource on the same machine as the current document. Relative URLs may contain relative path components (".." means one level up in the hierarchy defined by the path), and may contain fragment identifiers.
Relative URLs are resolved to full URLs using a base URL. [RFC1808] defines the normative algorithm for this process.
As an example of relative URL resolution, assume we have the base URL "http://www.acme.com/support/intro.html". The relative URL in the following markup for a hypertext link:
would expand to the full URL "http://www.acme.com/support/suppliers.html", while the relative URL in the following markup for an image
<IMG src="../icons/logo.gif" alt="logo">
would expand to the full URL "http://www.acme.com/icons/logo.gif".
In HTML, URLs play a role in these situations:
User agents should calculate the base URL for resolving relative URLs according to the [RFC1808]. The following is a summary of how [RFC1808] applies to HTML. User agents should calculate the base URL according to the following precedences (highest priority to lowest):
Additionally, the OBJECT and APPLET elements define attributes that take precedence over the value set by the BASE element. Please consult the definitions of these elements for more information about URL issues specific to them.
Link elements specified by HTTP headers are handled exactly as LINK elements that appear explicitly in a document.
In addition to HTTP URLs, authors might want to include MAILTO URLs (see [RFC1738]) in their documents. MAILTO URLs cause email to be sent to some email address. For instance, the author might create a link that, when activated, causes the user agent to open a mail program with the destination address in the "To:" field.
MAILTO URLs have the following syntax:
User agents may support MAILTO URL extensions that are not yet Internet standards (e.g., appending subject information to a URL with the syntax "?Subject=my%20subject" where any space characters are replaced by "%20"). Some user agents also support "?Cc=email-address".