What is a relative URL?

A Relative URL is targeted to a file or directory in relation to the present file or directory. If the web site has several sections and the files and web pages for each section have been segregated into different directories. This helps in keeping things organized and uncluttered on the web site. The relative URLs are shorter than absolute URLs and hence the file size of the web page would reduce, if you use the former.

For example:

If we want to include the image file hardware.gif stored in the images directory of www.thefreshcomputer.com domain on this page using a relative URL then the <img> tag for this image display will be as follows:

<img src=”../images/hardware.gif” width=”…” height=”…” />

Leave a Reply

Your email address will not be published. Required fields are marked *