A file path delineates the position of a file within a website’s directory structure.
File Path Examples
Path |
Description |
<img src=”picture.jpg”> |
The file “picture.jpg” resides in the identical folder as the current page. |
<img src=”images/picture.jpg”> |
The “picture.jpg” file is situated within the “images” folder within the current directory. |
<img src=”/images/picture.jpg”> |
The “picture.jpg” file is situated in the “images” folder at the root of the current website. |
<img src=”../picture.jpg”> |
The “picture.jpg” file is situated in the folder one level above the current directory. |
A file path delineates the location of a file within a website’s folder structure.
File paths are utilized when linking to external files such as:
An absolute file path represents the complete URL to a file.
Example
<img src=”https://www.w3schools.com/images/picture.jpg” alt=”Mountain”> |
A relative file path directs to a file relative to the current page.
In the given example, the file path directs to a file within the “images” folder situated at the root of the current website.
Example
<img src=”/images/picture.jpg” alt=”Mountain”> |
In this example, the file path indicates a file within the “images” folder within the current directory.
Example
<img src=”images/picture.jpg” alt=”Mountain”> |
In this example, the file path directs to a file within the “images” folder situated one level above the current directory.
Example
<img src=”../images/picture.jpg” alt=”Mountain”> |