# Relative Path

Definition of Relative Path in the Network Encyclopedia.

## What is Relative Path?

Relative Path is the hierarchical path that locates a file or folder on a file system starting from the current directory. The relative path is different from the absolute path, which locates the file or folder starting from the root of the file system.

## Example

If the current directory is C:\Windows, the relative path to the executable for the game of Solitaire, which is located in the current directory, is simply the name of the executable – sol.exe. If the current directory is C:\Windows\System, the relative path to Solitaire is ..\sol.exe.

In a UNIX file system, the syntax for relative paths is similar except that it uses forward slashes instead of backslashes to separate levels in the file system hierarchy.

### Relative Path in HTML

In HTML, a file path describes the location of a file in a web site’s folder structure.

File paths are used when linking to external files like web pages, images, style sheets, javascript files, etc. Those paths can be Absolute Paths or Relative Paths.

An absolute file path is the full URL to an internet file:

<img src="https://networkencyclopedia.com/images/image-1.jpg" alt="Img 1">

A relative file path points to a file relative to the current page. In this next example, the file path points to a file in the images folder located at the root of the current web:

<img src="../images/image-1.jpg" alt="Img 1">

In the next example, the file path points to a file in the images folder located in the folder one level above the current folder. It’s the same file but the page referring to this file is different:

<img src="../images/image-1.jpg" alt="Img 1">

#### “Relative Path” in other contexts

The idea of a “relative path” is also used in other naming contexts. For example, in Active Directory of Microsoft Windows Server, you can uniquely and globally specify directory objects using the object’s distinguished name, which provides a kind of absolute path within the directory starting at the root and terminating at the desired object. For example, the object representing the user Mitch Tulloch in the domain northwind.expedia.com has this distinguished name:

DC=com,DC=expedia,
DC=northwind,OU=Users,CN=Mitch Tulloch

If a search context is established as the Users container within the northwind.expedia.com domain, the relative distinguished name of the Mitch Tulloch object is simply

CN=Mitch Tulloch

This relative distinguished name uniquely identifies the desired object within the Users container in Active Directory.

A standard DOS path can consist of three components:

• A volume or drive letter followed by the volume separator (:).
• A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
• An optional filename. The directory separator character separates the file path and the filename.

If all three components are present, the path is absolute. If no volume or drive letter is specified and the directory name begins with the directory separator character, the path is relative from the root of the current drive. Otherwise, the path is relative to the current directory. The following table shows some possible directory and file paths.

PathDescription
C:\Documents\Newsletters\Summer2018.pdfAn absolute file path from the root of drive C:
\Program Files\Custom Utilities\StringFinder.exeAn absolute path from the root of the current drive.
2018\January.xlsxA relative path to a file in a subdirectory of the current directory.
..\Publications\TravelBrochure.pdfA relative path to file in a directory that is a peer of the current directory.
C:\Projects\apilibrary\apilibrary.slnAn absolute path to a file from the root of drive C:
C:Projects\apilibrary\apilibrary.slnA relative path from the current directory of the C: drive.