Learn how to use file paths in HTML
File paths are used to specify the location of files in HTML. Understanding file paths is crucial for linking to external resources like images, stylesheets, and other HTML pages.
An absolute path provides the full URL to a file:
<img src="https://www.example.com/images/picture.jpg" alt="Description">
Relative paths specify the location of a file relative to the current page:
<img src="images/picture.jpg" alt="Description"> // File in images folder in current directory
<img src="../images/picture.jpg" alt="Description"> // File in images folder one directory up
Root-relative paths start with a forward slash and are relative to the root of the website:
<img src="/images/picture.jpg" alt="Description">
Understanding and using file paths correctly is essential for creating well-structured and functional HTML documents.