Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRoss Horak
20,890 PointsMaking the distinction between URI's, URL's, and URN's
I wasn't 100% sure of the differences between URI's and URL's after this video's explanation so did some further research. I thought I would post the following article as it explains (and illustrates) very clearly the differences: https://danielmiessler.com/study/url-uri/
Ahmed Osman
4,849 PointsThank you
Tobias Edwards
14,458 PointsThank you, the instructor said "A URL is a URI that also contains...". This made me think a URI is a subset of URL, when in fact the inverse is true only. Very confusing
6 Answers
Mischa Yartsev
20,562 PointsThanks for the awesome article! Now it's a relief understanding the terms, because I was really struggling with it.
Here's short summary of an article mentioned above:
- URIs are identifiers, and that can mean name, location, or both.
- All URNs and URLs are URIs, but the opposite is not true.
- The part that makes something a URL is the combination of the name and an access method, such as https://, or mailto:
- All these bits are URIs, so saying that is always technically accurate, but if you are discussing something that’s both a full URL and a URI (which all URLs are), it’s best to call it a “URL” because it’s more specific.
URI is best used when you’re referring to a resource just by its name or some other fragment. And when you’re giving both the name of a resource and the method of accessing it (like a full URL), it’s best to call that a URL.
Luis Marsano
21,425 PointsI don't know about that article: it was commenting on a standard, which is clear enough on its own. Directly from the actual standard under URI, URL, and URN:
A URI can be further classified as a locator, a name, or both.
An individual scheme does not have to be classified as being just one of "name" or "locator". Instances of URIs from any given scheme may have the characteristics of names or locators or both, often depending on the persistence and care in the assignment of identifiers by the naming authority, rather than on any quality of the scheme. Future specifications and related documentation should use the general term "URI" rather than the more restrictive terms "URL" and "URN" [RFC3305].
"name" or "locator" is a characteristic of the particular URI, regardless of the scheme. I've seen http: URIs that don't resolve to anything in a web browser, yet are used for naming something that never changes (XML namespaces); they're clearly URNs. If a webmaster is fairly careless, resource URIs may change all the time, so the URI acts more as locator (where the resource happens to be now) than as name (a persistent identifier). If a URL is stable (ie, cool), then it's also a name/URN. It's all up to the authority creating the identifiers.
Moreover, the URI definition is quite clear:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
URIs are always full: scheme and all. Fragments aren't called URIs: they're just incomplete or partial URIs. Calling a fragment a URI is like calling a tire a car: imprecise, not better.
I'd say if you want to stress the URI resolves as the naming components suggest, then call it a URL. If you want to stress that it can serve as a stable name, then call it a URN. However, if you want to always be right, or it doesn't matter, call it URI as the standards do.
The standard is clear by itself without muddled articles.
Shiyu Hong
12,681 PointsThanks this really clears my confusion! Don't know why it gets down votes :(
Iskander Ismagilov
13,298 PointsThanks a lot for your post! That made clear understanding of the difference.
Loris Guerra
17,536 PointsVery interesting, thank you!
Mel Rumsey
Treehouse ModeratorThank you for sharing that :) It helped a ton. Wish we could upvote your post!
Young Bae
18,429 PointsYoung Bae
18,429 PointsThank you for sharing the post! :) It helps me a lot to understand the difference.