Contains information about how to fetch a resource from its location. For example:
/other/link.html (A relative URL, only useful in the context of another URL)
URLs always start with a protocol (
http) and usually contain information such as the network host name (
example.com) and often a document path (
/foo/mypage.html). URLs may have query parameters and fragment identifiers.
Identifies a resource by a unique and persistent name. It usually starts with the prefix
urn: For example:
urn:isbn:0451450523 to identify a book by its ISBN number.
urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 a globally unique identifier
urn:publishing:book - An XML namespace that identifies the document as a type of book.
URNs can identify ideas and concepts. They are not restricted to identifying documents. When a URN does represent a document, it can be translated into a URL by a "resolver". The document can then be downloaded from the URL.
URIs encompass URLs, URNs, and other ways to identify a resource.
An example of a URI that is neither a URL nor a URN would be a data URI such as
data:,Hello%20World. It is not a URL nor a URN because the URI contains the data. It neither names it, nor tells you how to locate it over the network.
There are also uniform resource citations (URCs) that point to meta data about a document rather than to the document itself. An example of a URC would be an identifier for viewing the source code of a web page:
view-source:http://example.com/. A URC is another type of URI that is neither URL nor URN.
Frequently Asked Questions
I've heard that I shouldn't say URL anymore, why?
The W3 spec for HTML says that the
href of an anchor tag can contain a URI, not just a URL. You should be able to put in a URN such as
<a href="urn:isbn:0451450523">. Your browser would then resolve that URN to a URL and download the book for you.
Do any browsers actually know how to fetch documents by URN?
Not that I know of, but modern web browser do implement the data URI scheme.
Does the difference between URL and URI have anything to do with whether it is relative or absolute?
No. Both relative and absolute URLs are URLs (and URIs.)
Does the difference between URL and URI have anything to do with whether it has query parameters?
No. Both URLs with and without query parameters are URLs (and URIs.)
Does the difference between URL and URI have anything to do with whether it has a fragment identifier?
No. Both URLs with and without fragment identifiers are URLs (and URIs.)
But doesn't the W3C now say that URLs and URIs are the same thing?
Yes. The W3C realized that there is a ton of confusion about this. They issued a URI clarification document that says that it is now OK to use the terms URL and URI interchangeably (to mean URI). It is no longer useful to strictly segment URIs into different types such as URL, URN, and URC.
Can a URI be both a URL and a URN?
The definition of URN is now looser than what I stated above. The latest RFC on URIs says that any URI can now be a URN (regardless of whether it starts with
urn:) as long as it has "the properties of a name." That is: It is globally unique and persistent even when the resource ceases to exist or becomes unavailable. An example: The the URIs used in HTML doctypes such as
http://www.w3.org/TR/html4/strict.dtd. That URI would continue to name the the HTML4 transitional doctype even if the page on the w3.org website were deleted.