A Relative link is a type of hyperlink that provides a pathway to another page or resource within the same website without specifying the entire URL. Unlike an absolute link, which points to a resource using a full URL, a relative link is based on the current URL of the page where the link is placed. This means that the path provided by a relative link is interpreted in relation to the current page’s location within the website’s directory structure.
For example, if a relative link is used on a page at the URL
http://non.agency/portfolio/index.html, and the link is specified as
../contact.html, the browser understands this as pointing to
http://non.agency/contact.html. Here, the
.. notation is used to move up one directory level from the current location, effectively navigating from the ‘portfolio’ directory back to the main directory to access the ‘contact.html’ page.
Using relative links can simplify website maintenance, especially when moving pages or resources within the site’s structure, as it eliminates the need to update the full URLs of internal links. It also helps in keeping the site more portable if it needs to be transferred to a different domain.