URI
URI 包含了 URL (Uniform Resource Locator) 和 URN (Uniform Resource Name)。
简单地说,URI 是一种标识,而 URL 表示某种东西的位置。但是这个位置本身也是一种标识,所以 URL 也是一种 URI。URN 表示一种物件的唯一标识,比如 urn:isbn:0451450523。
例子
URL:
http://example.com/mypage.htmlftp://example.com/download.zipmailto:user@example.comfile:///home/user/file.txttel:1-888-555-5555http://example.com/resource?foo=bar#fragment/other/link.html(A relative URL, only useful in the context of another URL)
URN:
urn:isbn:0451450523to identify a book by its ISBN number.urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66a globally unique identifierurn:publishing:book- An XML namespace that identifies the document as a type of book.
URI:
data:,Hello%20WorldData URIonlyiceMy nickname
使用 URI 的地方
- 规范上定义了 HTML
a标签的src属性使用的是 URI(而不是 URL),所以你给它写一个url:isbn:0451450523也是符合规范的,只是没有浏览器会去处理它 - XML 的
SYSTEM关键字后面的系统标识符,使用的是 URI