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.
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.
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.
Photo.jpg and photo.jpg are different files on a Linux server. Keep file names lowercase.my photo.jpg causes trouble. Use hyphens: my-photo.jpg.../ — a page inside a folder that links to a file in the main folder needs to go up one level first.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).
<!-- 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.
/ 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.images folder, CSS in a css folder. When the folders are tidy, the paths stay short and easy to check.Images/logo.png and images/logo.png are different files on a server.../ when the page is inside a subfolder — the image 404s and the page shows a broken icon.https:// address for your own images — if the domain ever changes, every link breaks. Relative paths move with the site.%20 in a URL and is easy to mistype.<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.<!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>
Change the code below and press Run to see the result instantly. No file to save, no login needed.
The questions learners ask most about this lesson — read the question, then open it to see the answer.
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.
It means go up one folder, and ../../ means go up two levels.
Use it only for files on other websites, because for your own files it breaks if the domain changes.
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.
Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.
Take the testPrefer watching? Video courses teach the same topics step by step.
Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.
Browse all coursesAsk about courses, website & more
Request human callback:
Please log in to download. You will stay on this page after logging in!
New here? Register now →