Compare the Difference Between Similar Terms

Difference Between

Home / Technology / IT / Internet / Difference Between an Absolute and a Relative URL

Difference Between an Absolute and a Relative URL

April 30, 2011 Posted by Roshan Ragel

an Absolute vs a Relative URL

Uniform Resource Locator (URL) is an address that specifies where a particular document or a resource is located on the World Wide Web (WWW). Best example of a URL is the address of a web page on the WWW such as http://www.cnn.com/. Absolute URL, also called an absolute link is a complete internet address that takes a user to the exact directory or file of a website. A Relative URL or a partial internet address, points to a directory or a file relative to the current directory or a file.

What is Absolute URL?

Absolute URL, which provides a complete address of a web page or a resource on the WWW, generally has the format given bellow.

protocol://hostname/other_details

Usually, the Hyper Text Transfer Protocol (http://) is used as the protocol section. But the protocol also could be ftp://, gopher://, or file://. The hostname is the name of the computer that the resource is residing. For example, the hostname of the CNN’s central web server is www.cnn.com. The other_details section includes information about directory and the file name. The exact meaning of the other_details section depends on both the protocol and host. The resource that is pointed by the absolute URL is normally resided on a file, but it can also be generated on the fly.

What is Relative URL?

As mentioned earlier, a relative URL points to a resource relative to the current directory or file. A relative URL can take several different forms. When referring to a file that resides in the same directory as the currently referred page, the relative URL can be simple as the name of the file itself. As an example, if you need to create a link in your home page to a file called my_name.html, which resides in the same directory as your home page, you can simply use the file name as follows:

<a href=”my_name.html”>My name</a>

If the file you need to link is within a sub directory of the referring page’s directory, you need to include the subdirectory name and the file name in the relative URL. For example if we are trying to link a file my_parents.html that is within a directory called parents, which actually resides inside the directory that contains your home page, the relative URL will look like the following.

<a href=”parents/my_parents.html”>My Parents</a>

Additionally, if you want to refer to a resource that resides on a directory that is in a higher level in the directory structure than the directory that contains the referring page, you can use two consecutive dots. For example, if you want to refer to a file called home.html that in a directory above your home page, you can use a relative URL as follows.

<a href=”../home.html”>Home</a>

Difference between Absolute URL and Relative URL

The main difference between an absolute URL and a relative URL is that, an absolute URL is a complete address that points to a file or a resource, while a relative URL points to a file relative to the current directory or file. Absolute URL contains more information than a relative URL, but using relative URLs are much easier since they are shorter and more portable. But relative URLs can only be used to refer to links that reside on the same server as the page that refers them.

Related posts:

Difference Between www (World Wide Web) and Internet Difference Between HTTP and HTTPS Difference Between domains .com and .com.au Difference Between Internet Explorer and Firefox Difference Between Flicker and Picasa web

Filed Under: Internet Tagged With: Absolute and Relative URL, absolute link, Absolute URL, Absolute URL format, Absolute URL vs Relative URL, complete internet address, File, FTP, gopher://, hostname, HTTP, Hyper-Text Transfer Protocol, partial internet address, protocol, Relative and Absolute URL, Relative URL, Relative URL and Absolute URL, relative url format, Relative URL vs Absolute URL, Uniform Resource Locator, URL, www

About the Author: Roshan Ragel

Dr.Roshan G. Ragel, is a Doctorate in Computer Science and Engineering and Member of IET (UK) and IEEE. His research interests include Micro-architectural aspects of Embedded Systems Design and their Security and Reliability issues.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between HTML and CSS

Difference Between Extortion and Blackmail

Difference Between Double Salt and Coordination Compound

Difference Between Double Salt and Coordination Compound

What is the Difference Between Daniel Cell and Leclanche Cell

What is the Difference Between Daniel Cell and Leclanche Cell

Difference Between Direct and Indirect Costs

Latest Posts

  • What is the Difference Between Hepatocellular Carcinoma and Cholangiocarcinoma
  • What is the Difference Between Medulla Oblongata and Spinal Cord
  • What is the Difference Between CHF and Pulmonary Edema
  • What is the Difference Between Bisphosphonates and Denosumab
  • What is the Difference Between Colles Fracture and Smith Fracture
  • What is the Difference Between Cutaneous and Mucocutaneous Leishmaniasis
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

Copyright © 2010-2018 Difference Between. All rights reserved. Terms of Use and Privacy Policy: Legal.