Difference between an Absolute URL and a Relative URL

In this tutorial, we will learn the difference between an absolute URL and a relative URL.

What is a URL?

A Uniform Resource Locator (URL) is an address that indicates the location of a specific file or resource on the World Wide Web (WWW). A URL specifies the site of a target saved on a local or networked computer. A file, directory, HTML page, image, application, and more can all be the target. The organization of your website’s URL and internal links is crucial to how well it works. This is crucial to ensuring that your website can be successfully crawled and indexed.

The address of a website on the internet, such as http://www.tutorialspoint.com, is the best illustration of a URL. The wrong type could impact your SEO strategy, making the site challenging for search engines to crawl. When choosing a URL, you have two main options: absolute and relative.

What is an Absolute URL?

All the details required to find a resource are in an absolute URL. It employs the following structure: scheme://server/path/resource, Where The scheme specifies the resource’s access method. The server determines the computer's name on which the resource is stored. The path specifies the order of directories leading to the target. The last directory in the way is the target if the resource is omitted. The resource is the target if it is present and is often the file’s name. It could be a structured document with one or more storages and binary bytes or a necessary file with a single binary stream of bytes.

Absolute URLs offer a full address for a website or other resource on the Internet. An absolute URL includes the position within your website in your folder system names within the URL and consists of the full address from the protocol (HTTPS) to the domain name (www.tutorialspoint.com).

In essence, it is the complete URL of the page that you are linking to.

For instance, the below URL is an absolute URL

<a href = "http://www.tutorialspoint.com/xyz.html">

Reason to choose Absolute URL

  • Foils Scrapers − When using absolute URLs, it is more difficult for others to use scraper tools to collect data from your site directory. It would be pretty simple for a scraper to scrape your entire website and put it up on a new domain if all of your internal links were relative URLs.

  • Prevents Duplicate Content Issues − Utilising absolute URLs to prevent duplicate content problems is crucial as an illustration. Imagine that you have different root domains that Google has indexed without a canonical tag that directs users to the correct version of the website.

1. http://www.tutorialspoint.com,

2. http://tutorialspoint.com,

3. http://www.tutorialspoint.com,

4. http://tutorialspoint.com

What is a Relative URL?

An absolute URL is the starting point for a relative URL, which locates a resource. A relative URL usually contains the path and, if present, the resource; it does not include the scheme or server. Concatenating the absolute and relative URLs effectively specifies the target’s “complete URL.”

This URL only includes the area after the domain and does not include the complete website address. It is presumptuous to presume that any links you add will be on the same website and belong to the same root domain.

The forward slash is the first character in the relative path, which directs the browser to stay on the current website. A relative URL would look like this −

<a href = "/xyz.html">

Reason to choose Relative URL

  • Quicker Coding − Shortening your URL into a relative format makes it considerably simpler to code large websites.

  • Staging Environment − If you use a content management system like WordPress or SharePoint that provides a staging environment with its distinct domain, your complete website is mirrored on that staging domain.

  • Quicker Load Times − Although the speed difference is minimal, pages using relative URLs generally load faster than ones using absolute URLs.

Difference between an Absolute URL and a Relative URL

The main difference between an absolute URL and a relative URL is this. A relative URL points to a file relative to the current directory or file, whereas an absolute URL is a complete address that leads to a file or resource. Since a relative URL is shorter and more portable than an absolute URL, which includes more information, it is simpler to utilize. But only links hosted on the same server as the page from which they are referred are allowed to use relative URLs.

Absolute URL Relative URL
The complete address of a document on the internet is known as an absolute URL. The relative URL is a document’s online partial address.
All the information needed to locate files online is contained in the absolute URL. Only file names or file names with folder names are contained in relative URLs.
The browser could not link to the precise line if the four components were missing. We can use this URL form when the file is on the same server as the original document.


There are advantages and disadvantages to both the relative and absolute paths. Make sure to select the best plan based on your SEO requirements.

There is no default, so you have an option. However, absolute URLs are often advised because they have more benefits than drawbacks and will boost the SEO of your website.

However, depending on your site’s requirements, there are situations when relative URLs will be the best choice.

Updated on: 06-Dec-2022

17K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started