How to give the path in HTML?

LAST READ: APR 19 2024 | Q. BY: EDWARD MIKE

N

Namrata

There are two way to provide a path in HTML

1 - Complete Path

2 - Relative Path

Complete Path - 

In this technics, we use the complete path of the file with domain URL, This technic is less recommended to use, I will tell the reason behind it at the end of the answer.

Example: http://www.gdatamart.com/html/html_intro.aspx

Relative Path - 

This technic is most preferable, In this technic, we map the path from the current file to the linking file in term of shortest distance. You can assume it as taking the shortest distance to reach from one point to another point. In the above example, http://www.gdatamart.com/ is the domain, html is the name of the folder, html_intro.aspx is the name of the file within html folder. There can be 3 conditions to provide a relative path

A - If HTML page in root directory

In this condition, we have to move in html folder then provide the file name

Example: html/html_intro.aspx

B - If Both file on at the same location

Now you can assume that both files are in html folder then, the path will be

Example: html_intro.aspx

C - If both files are in different folders

Suppose, the linking file in another folder of the root directory at the same level of html folder then the path is

Example: ../html/html_intro.aspx

Note: we use ../ to come out one level up, if we have to come out two levels up then we have to use ../../  and to going down in directories just use the folder names separated with / for example tutorials/html/ etc.

The reason why we should prefer the relative path

Suppose if we have a website with large numbers of pages and if in some situation we needed to change the domain name, In this condition, if we have relative path in website pages then there is no need to worry about directory otherwise if we have provided complete path then we needed to change domain name in each and every link. 

1 votes

Your Answer

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)