Go to main content
Bypass navigation bar HTML Reference HTML Tags HTML Tutorials
Bypass language selection
Bypass location bar

Location: Home > HTML Reference > URIs and URLs

Bypass main content

URIs and URLs

The World Wide Web can be conceived as a large group of resources placed in different computers all around the world. These resources can be found and linked through URIs. As its name describes, it identifies resources by assigning them addresses in a given network.

A URL is a type of URI that's used to describe the location of a specific document. A URL doesn't define the type of content to be found (texts, images, movies, etc.); it only says where and how to find it. A common URL is composed by four parts:

  • The protocol: Also called URL scheme, this specifies which protocol is used to access the document.
  • The computer name: Gives the name of the computer (usually a domain name or IP address) where the content is hosted.
  • The directories path: Secuence of directories separated by slashes that define the path to follow to reach the document.
  • The file name: The name of the file containing the resource.

This way we can analyze and split any given URL. For example, let's take a look at the URL of the HTML span element (http://www.htmlquick.com/reference/tags/span.html):

  • Protocol: http://
  • Computer name (domain name): www.htmlquick.com
  • Directories path: /reference/tags/
  • File name: span.html

Some URLs may not contain any directory, and other parts of it can be omitted depending on the case. For example, when the file is not defined in an HTTP request, web servers automatically send default files (e.g., index.html). Also, when typing a URL in some browsers, if the protocol is absent (e.g., www.servername.com/index.php), the empty space is automatically replaced by the HTTP protocol prefix (http://).

Below, are some examples of URLs:

ftp://someserver.com/some-res.php (no directories defined)
http://www.w3.org/TR/CSS21/ (no file specified)
http://www.htmlquick.com/reference/tags/a.html

Relative URIs

Relative URIs are partial URIs used to make a reference to a document from another one in the same computer. In other words, we can define a relative URI as the path to follow from the current document's location (directory path) to the destination resource.

To understand it better, supose the current document, located at "http://webserver.es/documents/index.asp", needs to point to a document located at "http://webserver.es/documents/new/best/two.asp". The relative URI to refer to that resource from the current document will be: "new/best/two.asp". If you take a closer look at the previous example, you can construct the destination URL (with an algorithm) only using the current document's URL and the relative URI.

The special directory ".." allows to go back to the parent directory. So, to point from "http://newwebserver.mil/documents/new/best/res.htm" to "http://newwebserver.mil/documents/old/best/june.htm", the relative URI will be: "../../old/best/june.htm".

For more information about interlinking resources, please refer to our "Organizing a website" tutorial.

Diseño y desarrollo: Latitud29.com

Links and logos|Contact|Beyond HTML|Tools and resources|Sitemap|Webmaster|Donate