The best answers to the question “What is the difference between a URI, a URL and a URN?” in the category Dev.
People talk about URLs, URIs, and URNs as if they’re different things, but they look the same to the naked eye.
What are the distinguishable differences between them?
From RFC 3986:
A URI can be further classified as a locator, a name, or both. The
term “Uniform Resource Locator” (URL) refers to the subset of URIs
that, in addition to identifying a resource, provide a means of
locating the resource by describing its primary access mechanism
(e.g., its network “location”). The term “Uniform Resource Name”
(URN) has been used historically to refer to both URIs under the
“urn” scheme [RFC2141], which are required to remain globally unique
and persistent even when the resource ceases to exist or becomes
unavailable, and to any other URI with the properties of a name.
So all URLs are URIs, and all URNs are URIs – but URNs and URLs are different, so you can’t say that all URIs are URLs.
If you haven’t already read Roger Pate’s answer, I’d advise doing so as well.
URIs identify and URLs locate; however, locators are also identifiers, so every URL is also a URI, but there are URIs which are not URLs.
- Roger Pate
This is my name, which is an identifier.
It is like a URI, but cannot be a URL, as it tells you nothing about my location or how to contact me.
In this case it also happens to identify at least 5 other people in the USA alone.
- 4914 West Bay Street, Nassau, Bahamas
This is a locator, which is an identifier for that physical location.
It is like both a URL and URI (since all URLs are URIs), and also identifies me indirectly as “resident of..”.
In this case it uniquely identifies me, but that would change if I get a roommate.
I say “like” because these examples do not follow the required syntax.
In computing, a Uniform Resource Locator (URL) is a subset of the Uniform Resource Identifier (URI) that specifies where an identified resource is available and the mechanism for retrieving it. In popular usage and in many technical documents and verbal discussions it is often incorrectly used as a synonym for URI, … [emphasis mine]
Because of this common confusion, many products and documentation incorrectly use one term instead of the other, assign their own distinction, or use them synonymously.
My name, Roger Pate, could be like a URN (Uniform Resource Name), except those are much more regulated and intended to be unique across both space and time.
Because I currently share this name with other people, it’s not globally unique and would not be appropriate as a URN. However, even if no other family used this name, I’m named after my paternal grandfather, so it still wouldn’t be unique across time. And even if that wasn’t the case, the possibility of naming my descendants after me make this unsuitable as a URN.
URNs are different from URLs in this rigid uniqueness constraint, even though they both share the syntax of URIs.
In summary: a URI identifies, a URL identifies and locates.
Consider a specific edition of Shakespeare’s play Romeo and Juliet, of which you have a digital copy on your home network.
You could identify the text as
That would be a URI, but more specifically a URN* because it names the text.
You could also identify the text as
That would also be a URI, but more specifically a URL because it locates the text.
*Uniform Resource Name
(Note that my example is adapted from Wikipedia)
URI — Uniform Resource Identifier
URIs are a standard for identifying documents using a short string of numbers, letters, and symbols. They are defined by RFC 3986 – Uniform Resource Identifier (URI): Generic Syntax. URLs, URNs, and URCs are all types of URI.
URL — Uniform Resource Locator
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.
URN — Uniform Resource Name
Identifies a resource by a unique and persistent name, but doesn’t necessarily tell you how to locate it on the internet. It usually starts with the prefix
urn: For example:
urn:isbn:0451450523to identify a book by its ISBN number.
urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66a 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.
URC — Uniform Resource Citation
Points to meta data about a document rather than to the document itself. An example of a URC is one that points to the HTML source code of a page like:
Rather than locating it on the internet, or naming it, data can be placed directly into a URI. An example would be
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.)
Does the difference between URL and URI have anything to do with what characters are permitted?
No. URLs are defined to be a strict subset of URIs. If a parser allows a character in a URL but not in a URI, there is a bug in the parser. The specs go into great detail about which characters are allowed in which parts of URLs and URIs. Some characters may be allowed only in some parts of the URL, but characters alone are not a difference between 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 URIs used in HTML doctypes such as
http://www.w3.org/TR/html4/strict.dtd. That URI would continue to name the HTML4 transitional doctype even if the page on the w3.org website were deleted.