An HTML file path tells the browser where to locate an image, stylesheet, script, or linked page. Choosing between relative paths, root-relative paths, and full absolute URLs prevents broken images and 404 errors when you move pages into subfolders.
photo.jpg looks in the same directory, images/photo.jpg steps into a subfolder, and ../css/main.css climbs one directory upward./images/photo.jpg) and always resolve from the domain root, no matter how deeply nested the current page URL is.https://cdn.example.com/app.js), used when loading resources from external hosts.<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML File Paths Demo</title>
<!-- Root-relative CSS path works from any nested route -->
<link rel="stylesheet" href="/assets/css/main.css">
</head>
<body>
<!-- Same folder as current HTML file -->
<a href="contact.html">Contact (Same Folder)</a>
<!-- One folder up into shared images directory -->
<img src="../images/diagram.webp" alt="Architecture diagram" width="480" height="270">
<!-- External absolute URL -->
<a href="https://developer.mozilla.org" target="_blank" rel="noopener noreferrer">External Docs</a>
</body>
</html>
Windows and macOS filesystems ignore filename casing during local development, so Avatar.WEBP matches avatar.webp on your laptop. Once deployed to a Linux web server, filenames become strictly case-sensitive and Avatar.WEBP triggers a 404 error. Always keep folders and filenames lowercase with hyphens.
C:\Users\Name\... local Windows paths: Hardcoded local drive paths work only on your own PC and fail for every visitor online./tutorials/html/lesson/intro treats styles.css as /tutorials/html/lesson/styles.css. Use root-relative /styles.css instead.\ instead of forward slashes /**: Web URLs always use forward slashes /.../ tells the browser to step up one parent directory from the current file's location before looking for the next folder or file.
Use root-relative paths like /images/banner.webp on multi-page websites and frameworks so shared assets work from any nested URL.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.