You click a link on your HTML page…
And instead of opening the page, you see:
- 404 Not Found
- Blank page
- Nothing happens at all 😐
For beginners, this feels confusing because the <a> tag looks perfectly correct.
In reality, most HTML link problems happen because of path confusion — especially relative vs absolute paths.
When I was learning HTML, I once uploaded my site and every link broke — even though everything worked locally. The issue was simple: my files were named About.html locally but about.html on the server. That mistake taught me how strict hosting environments really are.
In this guide, I’ll explain why your HTML links are not working, in the simplest way possible, using real beginner mistakes and clear examples.
1. What an HTML Link Actually Does
A basic HTML link looks like this:
|
1 |
<a href="about.html">About</a> |
When clicked, the browser:
- Starts from the current page location
- Looks for the file you mentioned
- Opens it if found
If it can’t find it → link breaks.
2. Most Common Reason: Wrong File Location
Let’s say your folder structure is:
|
1 2 3 4 |
project/ +-- pages/ ¦ +-- about.html +-- index.html |
If you write:
|
1 |
<a href="about.html">About</a> |
❌ This will NOT work
Because about.html is inside /pages/, not beside index.html.
✅ Correct relative path:
|
1 |
<a href="pages/about.html">About</a> |
3. What Is a Relative Path? (Simple Explanation)
A relative path starts from the current file’s location.
Examples:
|
1 2 3 |
href="about.html" href="pages/about.html" href="../contact.html" |
Meaning:
- about.html → same folder
- pages/about.html → inside pages folder
- ../contact.html → go one folder back
4. Relative Path Mistake Beginners Make
You are inside:
|
1 |
project/pages/about.html |
And link to:
|
1 |
<a href="contact.html">Contact</a> |
Browser looks for:
|
1 |
project/pages/contact.html |
But file is actually:
|
1 |
project/contact.html |
✅ Correct link:
|
1 |
<a href="../contact.html">Contact</a> |
5. What Is an Absolute Path?
An absolute path gives the full location.
Example (website URL):
|
1 |
<a href="https://example.com/contact.html">Contact</a> |
This works from any page, because the browser knows exactly where to go.
6. Absolute Path vs Root-Relative Path (Important)
Many beginners confuse these two.
Absolute URL:
|
1 |
href="https://example.com/about.html" |
Root-relative path:
|
1 |
href="/about.html" |
Root-relative means:
Start from website root folder (public_html)
7. Why /about.html Works Online but Not Locally
When you open HTML files directly:
|
1 |
file:///C:/project/index.html |
Root / does not exist like a server.
So:
|
1 |
<a href="/about.html"> |
❌ Often fails locally
✅ Works on hosting
This confuses beginners a lot.
8. File Name and Case Sensitivity Issue
Works on Windows:
|
1 |
<a href="About.html"> |
Fails on hosting if file is:
|
1 |
about.html |
Linux servers are case-sensitive.
✅ Always use lowercase names.
9. Missing .html Extension
Sometimes beginners forget extensions.
❌ Example:
|
1 |
<a href="about">About</a> |
Unless you’re using routing or backend, this won’t work.
✅ Fix:
|
1 |
<a href="about.html">About</a> |
10. Link Works Locally but Breaks After Upload
This usually happens because:
- Folder structure changed
- Case mismatch
- Root-relative paths misused
✅ Fix:
- Recheck hosting folders
- Open target file URL directly
- Match paths exactly
How to Debug a Broken HTML Link (Pro Method)
- Right-click link → Copy link address
- Paste in browser
- If it opens → link correct
- If not → path problem
You can also:
- Inspect → Network → click link → check 404
My personal rule: if a link fails, I always paste the URL directly into the browser first. If it shows 404, I stop checking HTML and fix the path.
HTML Links Not Working — Common Beginner Questions
Why does my link show 404?
Because the browser cannot find the file at the given path.
Why does it work locally but not after upload?
Hosting servers are case-sensitive and treat root paths differently.
Should I use relative or absolute paths?
Relative paths are better for small projects; absolute URLs for external pages.
Beginner Mistakes Tutorials Don’t Explain
- Difference between relative, root-relative, and absolute paths
- Root path behaving differently locally vs online
- Case sensitivity on servers
- Folder structure confusion
That’s why HTML links feel hard at first.
Quick Fix Checklist
If your HTML links are not working:
- ✔ Correct folder path
- ✔ Correct file name & extension
- ✔ Lowercase filenames
- ✔ Relative path used correctly
- ✔ Avoid / locally
- ✔ Hard refresh browser
Final Thoughts
HTML links don’t break randomly.
They break because the browser can’t find the file.
Once you truly understand relative vs absolute paths,
you’ll fix broken links in seconds — not hours.
Every developer struggled with this at the start. You’re learning the right way 💪
