HTML File Paths

HTML File Paths
Correct file paths are essential—a small mistake and your image/CSS/JS won’t load.
1. What Is a File Path?
A file path specifies the location of a file inside your website/project.
Used in tags like:
2. Types of File Paths
There are two main types:
Relative File Path (Most Common)
Based on the current HTML file
Short and portable
Recommended for websites
Absolute File Path
Full URL or full system path
Not recommended for local projects
3. Relative File Paths (Important )
Example Folder Structure
Same Folder
Inside a Folder
Go One Level Up (../)
../ means go back one folder
Go Two Levels Up
4. Absolute File Paths
Website URL (Allowed but not ideal)
Local System Path (Bad Practice)
Works only on your computer, not on the web
5. Root-Relative Paths (/)
Root-relative paths start from the website root.
- Useful in large websites
- Needs correct server root
6. File Paths for Common Elements
CSS
JavaScript
Image
Link to Another Page
7. File Paths from Subfolders
If about.html is inside a folder:
To load CSS:
Common Mistakes
- Wrong folder name
- Missing
../ Using backslashes\instead of/Case mismatch (Logo.png≠logo.png)- Using absolute system paths
Quick Reference
| Symbol | Meaning |
|---|---|
file.jpg | Same folder |
folder/file.jpg | Inside folder |
../file.jpg | One folder up |
/file.jpg | From root |
https:// | Absolute URL |
Key Points to Remember
Prefer relative paths
Use
/(not\)Paths are case-sensitive
Match folder structure exactly
Test paths carefully
