File Path HTML
File Path HTML
❮ PreviousNext ❯
A file path describes the location of a file in a web site's folder structure.
<img src="picture.jpg"> The "picture.jpg" file is located in the same folder as the
page
<img src="../picture.jpg"> The "picture.jpg" file is located in the folder one level up
current folder
Web pages
Images
Style sheets
JavaScripts
Example
<img src="https://www.w3schools.com/images/picture.jpg" al
t="Mountain">
Try it Yourself »
The <img> tag is explained in the chapter: HTML Images.
ADVERTISEMENT
In the following example, the file path points to a file in the images folder
located at the root of the current web:
Example
<img src="/images/picture.jpg" alt="Mountain">
Try it Yourself »
In the following example, the file path points to a file in the images folder
located in the current folder:
Example
<img src="images/picture.jpg" alt="Mountain">
Try it Yourself »
In the following example, the file path points to a file in the images folder
located in the folder one level up from the current folder:
Example
<img src="../images/picture.jpg" alt="Mountain">
Try it Yourself »
Best Practice
It is best practice to use relative file paths (if possible).
When using relative file paths, your web pages will not be bound to your current
base URL. All links will work on your own computer (localhost) as well as on your
current public domain and your future public domains.