logo Learn HTML
  • Home
  • Tutorials
  • Practice
  • Quiz
  • Projects
  • About
  • Contact

HTML Course

  • HTML HOME
  • HTML Introduction
  • HTML Basic
  • HTML Element
  • HTML Attributes
  • HTML Headings
  • HTML Paragrapha
  • HTML Style
  • HTML Formattin
  • HTML Quotations
  • HTML Colors
  • HTML Css
  • HTML Links
  • HTML Image
  • HTML Favicon
  • Page Tittle
  • HTML Tables
  • HTML Lists
  • Block & Inline
  • HTML Div
  • HTML Classes
  • HTML Id
  • HTML Buttons
  • HTML Iframes
  • HTML File Paths
  • HTML Head
  • HTML Layout
  • HTML Symbols
  • HTML Emojis
  • HTML URL Encode
  • HTML VS XHTML
  • HTML FROM
  • HTML Form
  • Form Attributes
  • Form Elements
  • HTML Input Types
  • HTML Input Attributes
  • Input Form Attributes
  • HTML Graphics
  • HTML Canvas
  • HTML SVG
  • HTML Media
  • HTML Media
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML Youtube
  • HTML APIS
  • HTML Web APIS
  • HTML Geolocation
  • HTML Drag & Drop
  • Web Storage
  • Web Workers
  • HTML SSE
  • HTML Examples
  • HTML Examples
  • HTML Editor
  • HTML Quiz
  • HTML Exercises
  • HTML References
  • HTML Tag List
  • HTML Attributes
  • HTML Global Attributes
  • HTML Brower Support
  • HTML Events
  • HTML Colors
  • HTML Canvas
  • HTML Audio & Video
  • HTML Doctypes
  • HTML Character Sets
  • HTML URL Encode
  • Language Codes
  • HTTP Messages
  • HTTP Methods
  • PX to EM Converter
  • keyboard Shortcuts

HTML File Paths

A file path shows the exact location of a file inside a website's folder structure.

File paths are commonly used when connecting external resources to your webpage, such as:

  • Other HTML pages

  • Images

  • CSS files

  • JavaScript files


Understanding file paths is essential for building structured and well-organized websites.


Common File Path Examples

This means the file picture.jpg is located in the same directory as the current HTML file.

<img src="picture.jpg" alt="Image" />



File Inside a Subfolder


<img src="images/picture.jpg" alt="Image" />


This means the image is inside a folder named images, which is located in the same folder as the current page.


File from the Root Folder


<img src="/images/picture.jpg" alt="Image" />


The forward slash / at the beginning refers to the root directory of the website. This means the images folder is placed at the top level of the website.


Absolute File Paths

An absolute file path contains the complete web address (full URL) of a file.

Example

<img src="https://example.com/images/picture.jpg" alt="Mountain" />


This loads the image directly from a specific website address.

Absolute paths always include:

  • Protocol (https://)

  • Domain name

  • Full file location


Relative File Paths

A relative file path points to a file based on the current page's location.

From Root Folder

Example

<img src="/images/picture.jpg" alt="Mountain" />


From Current Folder

Example

<img src="images/picture.jpg" alt="Mountain" />


From One Level Up

Example

<img src="../images/picture.jpg" alt="Mountain" />


Relative paths do not include the domain name.


Best Practice

Using relative file paths is generally recommended when possible.

Advantages:
  • Works on localhost (your computer)

  • Works on live servers

  • Easier to move the website to a new domain

  • Keeps your project flexible and portable


Try It Your Self

Sign Up For New
Update

HTML Basic
  1. HTML Basic
  2. HTML Element
  3. HTML Attributes
  4. HTML Headings
  5. HTML Paragrapha
  6. HTML Tables
  7. HTML Lists
HTML Advance
  1. HTML Div
  2. HTML Classes
  3. HTML Id
  4. HTML Buttons
  5. HTML Iframes
  6. HTML Symbols
  7. HTML Emojis