Explanation and example about relative and absolute path.

Question

I would like an explanation and example about the relative path and absolute path.

Explanation

File-path is an address. And that address is used to find any web page through files and folders. It can be present in the same location or another. And files can be anything such as photos, videos, and audio.

There are two types of file paths:
⦁ An absolute path, and
⦁ Relative path

Explanation and example about relative and absolute path are as follows:

Absolute Path:

This is use to specify the address of a file that is present at a location on some other network. So we include the full address of the location i.e. URL. In URL, first the protocol is specified followed by the domain name.
https://amazon.com/electronics ..will open electronics on amazon webpage.
https://pexel.com ..will direct you to pixel home page.

Relative Path:

Relative path means if the file that we are searching is in the same directory or in the root directory. Also relative path have also the complete address where the file is located. Including the parent files and directories. And also it carry the name and the directory.
Relative Path is a path used when the file which is in the same directory or in the root directory is accessed. Relative path has the complete address of the file including the parent files and directories.
The relative paths have the file name and the directory.

There are different ways by which we can specify the path name:

      • If the file is included with the same directory as that or the web page, then we use
        <filename.html>
      • If the file is included in the different directory, then the directory is to be mentioned like as given below:
        <directory/filename.html>
      • Even, to indicate the parent name directly, “..//” can be used like
        <../../filename.html>

 

Also read, For these situations, just design the h files you need to implement the classes you’d need.

 

Share this post

Leave a Reply

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