As from the name we can feel this is something related to each other so yes relative links are related to same site and directories and files inside same site. When we make our website we usually use relative links cause these links increase speed of our site. So basically relative link is a link which is related to other pages of same site or other directories of same site.
What is relative link?
Suppose your site have 3 pages gallery.php, products.php, index.php where index.php is your main site’s home page and when you want to link gallery.php inside your home page you will just do like this <a href=”gallery.php” this way browser will see for gallery.php inside your site’s server where index.php actually is so relative links are we link our pages by just their file or directory name. Not giving full url with site’s address.
How relative link works?
When we open http://www.mysite.com/index.php in browser then browser read it’s all links carefully and decide which links are relative, the links with just page names, or directory names browser consider them relative links and if we click on those links browser will not go back to internet cause browser will see those pages or directories only inside our server. Means browser will not search outside http://www.mysite.com/ cause this is the address for relative files for browser.
Benefits of relative links
As if we use relative links our browser do not need to go out to internet again and again for each our page and browser can know where to find those pages easily this increase speed of browsing our site a bit not much but just a bit. Also there is no advantage or disadvantage of relative links according to search engines.
Examples of relative links.
Here i am gonna make some relative links with some pages and directories inside same site. As you know we cannot link anything out of our site relatively means you cannot make relative link to other site. Browser will not understand that. See how to make relative link to folders as well.
<!-- Relative links to files-->
<a href="index.php">Home</a>
<a href="contact.php">Contact Us</a>
<!--relative links to folders-->
<a href=""/products/">Products</a>
<a href="/gallery/index.php"">Gallery</a>
Read about Relative Links
Read About Absolute Links
Find out difference between absolute links and relative links.