Open In App

How Absolute URL is Different from Relative URLs?

Last Updated : 21 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Answer: Absolute URLs specify the full path to a resource including the protocol and domain name, while relative URLs specify a path relative to the current URL’s base path.

Understanding the distinction between absolute and relative URLs is crucial for web development and navigation:

Absolute URLs

An absolute URL provides the complete address of a webpage or file on the internet, including the protocol “http:// or https://” domain, and path to the resource.

eg. https://www.example.com/images/logo.png

Relative URLs

A relative URL specifies the path to a resource about the current document’s path or the base URL of the website, without the domain name and protocol.

Example: If the current URL is “https://www.example.com/about/team.html”, a relative URL to another page in the same directory like contact.html would simply be contact.html.

Conclusion

Absolute URLs are used when referring to resources across different websites or domains, providing a complete path that can be accessed from anywhere on the web. Making the site easier to maintain and quicker to update, as paths are shorter and based on the document’s current location.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads