In HTML, URLs are used to specify the location of web resources such as web pages, images, or other files. There are two types of URLs: absolute URLs and relative URLs.
An absolute URL specifies the complete address of a web resource, including the protocol, domain name, and path. Here’s an example of an absolute URL:
In this example, “https://” is the protocol, “www.example.com” is the domain name, and “/images/picture.jpg” is the path to the image file.
A relative URL specifies the location of a web resource relative to the current page. Relative URLs can be shorter and easier to maintain than absolute URLs because they only specify the path from the current page to the resource. Here’s an example of a relative URL:
images/picture.jpg
In this example, the path to the image file is relative to the location of the current web page.
It’s important to note that when using a relative URL, the browser will use the current page’s URL as the base URL to resolve the relative URL. If the current page’s URL changes, the relative URL may no longer work correctly. In contrast, absolute URLs always specify the complete address of the resource, so they don’t depend on the current page’s URL.