HTML File Paths
A file path tells us where a file is located in a website's folders.
File Path Examples
Path | Description |
---|---|
<img src="picture.jpg"> | The "picture.jpg" file is in the same folder as the current page. |
<img src="images/picture.jpg"> | The "picture.jpg" file is located in the images folder in the current directory. |
<img src="/images/picture.jpg"> | The "picture.jpg" file can be found in the "images" folder within the present directory. |
<img src="../picture.jpg"> | The "picture.jpg" file is situated in the folder that is one level above the current directory. |
HTML File Paths
A file path tells you where a file is located within a website's folders.
File paths are utilized for linking to outside files, such as:
- Web pages
- Images
- Style sheets
- JavaScripts
Absolute File Paths
An absolute file path is like the complete web address for a file: it shows exactly where the file is located.
Relative File Paths
A relative file path directs to a file located near the current page.
In this example, the file path directs to a file inside the "images" folder at the main location of the current website.
When you use relative file paths, your web pages won't be tied to a specific starting web address. This means links will function on your computer (localhost) and any present or future public domains you use.