The Fundamental Truth
A website is not one single file. It's a collection of different files (HTML, CSS, JavaScript, images, videos, fonts) that all need to work together.
Image: Website Folder Structure
Relative File Paths
Relative paths give directions to a file starting from the location of the file you are currently in.
Example Folder Structure:
my-website/
├── index.html
├── about.html
│
├── images/
│ ├── logo.png
│ └── hero.jpg
│
└── pages/
├── contact.html
└── terms.html
Image: Relative Path Visualization
Same Folder:
<a href="about.html">About Us</a>
Sub-folder (Going Down):
<img src="images/logo.png" alt="My Website Logo">
Parent Folder (Going Up):
<img src="../images/logo.png" alt="My Website Logo">
Key Point:
Use ../ to go up one level in the folder hierarchy. Each ../ moves up one folder.
Absolute File Paths
Absolute paths give the full URL to a resource on the web. Use these for external resources.
<a href="https://www.google.com">Search on Google</a>
Warning:
Never use absolute paths for your own files (like C:/Users/YourName/website/image.png). These will break when you upload your site to a server!