SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 25 of 35

HTML File Paths: Relative vs Absolute Paths Explained

4 min read · Free · No login needed

Every time you link to a page, an image, or a CSS file, you write a path — the address of that file. Paths come in two kinds: relative and absolute. Getting them right is one of the most common beginner problems, so it is worth learning properly.

Diagram — see how it fits together
Infographic: absolute vs relative file paths

Relative paths

A relative path describes where the file is from the current page. If the image sits in the same folder: src="photo.jpg". In a subfolder: src="images/photo.jpg". In the parent folder (one level up): src="../photo.jpg". Each ../ goes up one level. Relative paths are what you should use inside your own website — the site keeps working even if you move it to a different domain.

Absolute paths

An absolute path is the full address: https://kamaldnp.com/images/photo.jpg. Use it only for files on other websites. Never use it for your own files — if the domain changes, every link breaks.

Common mistakes

  • Wrong capital letters — Photo.jpg and photo.jpg are different files on a Linux server. Keep file names lowercase.
  • Spaces in file names — my photo.jpg causes trouble. Use hyphens: my-photo.jpg.
  • Forgetting ../ — a page inside a folder that links to a file in the main folder needs to go up one level first.
Tip: When an image does not load, right-click the broken-image icon and choose "Open image in new tab". The address bar shows exactly what path the browser tried — and the mistake becomes obvious.

What a file path is

A file path is the address of a file, written relative to where your page is. It tells the browser where to find an image, a stylesheet, or another page. There are three kinds: relative paths (from this page), root-relative paths (from the top of the site), and absolute paths (the full web address).

Syntax — path examples

<!-- same folder as this page -->
<img src="logo.png">

<!-- one folder down, inside "images" -->
<img src="images/logo.png">

<!-- one folder up, then into "images" -->
<img src="../images/logo.png">

<!-- from the top of the website -->
<img src="/images/logo.png">

<!-- full web address -->
<img src="https://kamaldnp.com/images/logo.png">

Read ../ as "go up one folder". Two dots, one slash, means one level up. ../../ means two levels up.

Note: A path that starts with / starts from the top of the website, not from your computer. On your own computer, /images/logo.png will not work when you open the file directly — it only works once the site is on a server. During practice, prefer relative paths.
Tip: Keep your files tidy: HTML files in the main folder, images in an images folder, CSS in a css folder. When the folders are tidy, the paths stay short and easy to check.

Common mistakes

  • Wrong capital letters — Images/logo.png and images/logo.png are different files on a server.
  • Forgetting ../ when the page is inside a subfolder — the image 404s and the page shows a broken icon.
  • Using a full https:// address for your own images — if the domain ever changes, every link breaks. Relative paths move with the site.
  • Spaces in file and folder names — a space becomes %20 in a URL and is easy to mistype.

Example explained

  • <img src="images/photo.jpg"> — a relative path going one folder down, into the "images" folder.
  • <img src="../logo.png"> — ../ means "go up one folder", so this finds the logo in the parent folder.
  • <a href="about.html"> — a link to a page in the same folder, so no folder name is needed.
  • <a href="https://kamaldnp.com"> — an absolute path, the full web address, used here because the page is on a different website.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>File Paths</title>
</head>
<body>

<img src="images/photo.jpg" alt="Photo in a subfolder">
<img src="../logo.png" alt="Logo in the parent folder">
<a href="about.html">About (same folder)</a>
<a href="https://kamaldnp.com">KAMALDNP (absolute)</a>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML File Paths: Relative vs Absolute Paths Explained

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What is a relative file path?

It describes where a file is from the current page, such as photo.jpg in the same folder or images/photo.jpg in a subfolder.

2. What does ../ mean in a file path?

It means go up one folder, and ../../ means go up two levels.

3. When should you use an absolute path?

Use it only for files on other websites, because for your own files it breaks if the domain changes.

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Full Stack PHP Development Course 2026
₹3,000
View
CapCut Mobile Video Editing Course Beginner to Advance
₹99
View
Advanced Cyber Security Industrial Training
₹5,000
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →