An HTML file path describes where a file lives in your site’s folder structure (or on another server). You use paths whenever a page links to images, stylesheets, scripts, or other pages.
What are file paths for in an HTML tutorial?
Tell the browser how to fetch photo.jpg, styles.css, or about.html. Wrong paths cause broken images and 404s; correct paths keep assets working on localhost and production.
Where do paths appear?
In URL attributes: src on <img> / <script> / <iframe>, href on <a> / <link>, and similar attributes on forms and media.
When should you use each kind?
Prefer relative or root-relative paths for your own files. Use a full absolute URL when the resource lives on another domain (CDN or third party).
Best practice.
Relative paths are not tied to one domain. The same markup often works on your computer, staging, and the live site.
Case and spelling matter.
Many hosts treat Photo.JPG and photo.jpg as different files. Match folder and file names exactly.
URL vs path.
A full URL includes scheme and host (https://…). A path alone (/images/a.jpg or ../a.jpg) is resolved against the current page URL.
Syntax
HTML File Path Syntax
Common forms (shown with <img>):
paths.html
<imgsrc="path-or-URL" alt="…">
HTML
<!-- Absolute URL (full address) -->
<img src="https://example.com/images/photo.jpg" alt="Photo">
<!-- Same folder as the HTML file -->
<img src="photo.jpg" alt="Photo">
<img src="./photo.jpg" alt="Photo">
<!-- Subfolder of the current folder -->
<img src="images/photo.jpg" alt="Photo">
<!-- One folder up, then into images/ -->
<img src="../images/photo.jpg" alt="Photo">
<!-- From the site root -->
<img src="/images/photo.jpg" alt="Photo">
The same path strings work in href, src on scripts, and other URL attributes.
Reference
Core HTML Concepts
How each path form is resolved:
Path
Meaning
https://example.com/img/a.jpg
Absolute URL — full address including host
photo.jpg or ./photo.jpg
Same folder as the current page
images/photo.jpg
images folder inside the current folder
../images/photo.jpg
Up one folder, then into images
/images/photo.jpg
Root-relative — from the website root
Absolute URL vs path
Absolute URL
Relative / root path
Includes domain?
Yes
No
Depends on page folder?
No
Relative: yes · Root (/): no
Best for
CDN / other sites
Your own site files
Approach
How to Choose a File Path
Practical habits for reliable links.
Sketch your folder tree (for example site/, site/images/, site/pages/).
From the HTML file’s folder, decide: same folder, child folder, parent, or site root.
Use ../ only as many times as you need to climb.
Use /… for shared assets that every page should reach the same way.
Use a full https://… URL for external hosts.
Test after moving pages between folders—relative links often break first.
Goal
Pattern
Asset next to the page
src="logo.png"
Asset in a subfolder
src="images/logo.png"
Climb then enter a folder
src="../images/logo.png"
Sitewide asset
src="/images/logo.png"
External / CDN
src="https://cdn.example.com/logo.png"
Try it
Live Preview
Pick a path form and see how it is described relative to a sample folder layout.
Assume the HTML page is at /blog/post.html. The demo image uses a working placeholder URL.
Rendered page
Code
HTML Examples
Six patterns: absolute URL, same folder, subfolder, parent folder, root-relative, and mixed assets on one page.
Path: ../images/photo.jpg — climb one level, then open images.
How It Works
../ moves up one directory.
Stack../../ to climb two levels, and so on.
Common when pages live in a pages/ or blog/ folder.
Easy to break if you reorganize folders later.
Example 5 — Root-Relative Path
HTML
<!-- Always from the site root, no matter where the page lives -->
<img src="/images/photo.jpg" alt="Landscape">
<link rel="stylesheet" href="/styles/main.css">
CSS/JS root paths and relative image/link paths can coexist.
How It Works
Root-relative CSS and JS stay stable sitewide.
../images reaches shared media from a nested page.
about.html is a same-folder relative link.
https:// opens an external absolute URL.
Edge Cases & Pitfalls
Most “missing image” bugs are wrong relative paths after a folder move—not broken browsers.
move
Moving HTML without updating paths
Relative links are tied to the page location. After relocating a file, re-check every src and href.
slash
Confusing /images with images/
/images/ is root-relative; images/ is under the current folder. They resolve differently.
case
Case sensitivity on the server
Windows may forgive case; Linux hosting often does not. Match exact casing.
spaces
Spaces in file names
Prefer hyphens. If a name has spaces, encode them as %20 in URLs.
base
<base href> changes resolution
A <base> element rewrites how relative URLs resolve for the whole document. Use sparingly.
file
Opening via file://
Root-relative / paths expect a web server root. Prefer a local server when testing sitewide assets.
Compatibility
Browser Support
Absolute and relative URL resolution is part of how every browser loads HTML resources.
✓ Baseline · Widely available
HTML file paths
Browsers resolve src and href the same way across platforms. Correct paths—not special APIs—are what make assets load.
100%URL resolution
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
HTML pathsUniversal
Bottom line: Focus on the right path form for your folder layout—browser support for loading linked files is not the limiting factor.
Remember
Key Takeaways
Absolute URLs include the host; use them for other domains.
./ and ../ navigate from the current page’s folder.
Leading / is root-relative from the website root.
Prefer relative paths for your own site when possible.
One line: Point src/href at the right place with a full URL, a relative path (./, ../, folders), or a root-relative / path—matching how your folders are laid out.
Frequently Asked Questions
A file path tells the browser where to find a resource—an image, stylesheet, script, or linked page. You write paths in attributes such as src, href, and action.
An absolute path (full URL) includes the protocol and domain, such as https://example.com/img/photo.jpg. A relative path is resolved from the current page’s location (or from the site root if it starts with /).
./ means the current folder (often optional). ../ moves one folder up. You can stack ../ to climb multiple levels before entering another folder.
A path that starts with / is resolved from the website’s root, not from the current page’s folder. Example: /images/logo.png always means site-root/images/logo.png.
Use a full absolute URL when the file lives on another domain (CDN, third-party host). Prefer relative or root-relative paths for your own site so links keep working across localhost and production.
Yes. The same absolute, relative, and root-relative rules apply to src on img/script, href on link/a, and similar URL attributes.