HTML File Paths
On this page
HTML File Paths
A file path describes the location of a file in a website’s folder structure.
File paths are used to link to resources such as web pages, images, stylesheets, and JavaScript files.
File Path Examples
| Path | Description |
|---|---|
picture.jpg | The file is located in the same folder as the current page |
images/picture.jpg | The file is located in the images folder inside the current folder |
/images/picture.jpg | The file is located in the images folder at the root of the website |
../picture.jpg | The file is located one folder level above the current folder |
Absolute File Paths
An absolute file path is the full URL to a file.
Absolute paths always include the protocol and domain name.
<img src="https://www.w3schools.com/images/picture.jpg" alt="Mountain">
Relative File Paths
A relative file path points to a file based on the location of the current page.
Relative paths are commonly used for files within the same website.
Relative Path Examples
Image located in the root images folder:
<img src="/images/picture.jpg" alt="Mountain">
Image located in an images folder inside the current folder:
<img src="images/picture.jpg" alt="Mountain">
Image located in an images folder one level above:
<img src="../images/picture.jpg" alt="Mountain">
Chapter Summary
- File paths describe where files are located in a website
- Absolute paths use full URLs
- Relative paths are based on the current file location
- File paths are used for images, pages, CSS, and JavaScript files