URLs are used in HTML links to point to other web pages or resources. There are two main types of URLs used in links: absolute and relative.
An absolute URL includes the complete address of a resource, including the protocol, domain name, and path.
<a href="https://www.example.com/about.html">About Us</a>
This link will work from any webpage because it contains the full address.
A relative URL points to a resource based on the current page’s location. It does not include the protocol or domain name.
<a href="about.html">About Us</a>
This link works only if about.html is in the same directory as the current page.
| Feature | Absolute URL | Relative URL |
|---|---|---|
| Address | Full web address | Partial path |
| Includes Domain | Yes | No |
| Portability | Works everywhere | Depends on file location |
| Usage | External links | Internal links |
Absolute and relative URLs serve different purposes in HTML links. Understanding when to use each helps build flexible and well-structured websites.
Choosing the correct URL type improves site maintenance and link management.