HTML File Paths

HTML File Paths

HTML file paths specify the location of files like images, CSS, or links in your HTML document. Paths can be absolute or relative.


1. Absolute Path

  • Specifies the full URL of the file.

  • Always works regardless of the HTML file location.

Example:


 

Output: Displays the image from the website.


2. Relative Path

  • Specifies the file relative to the HTML file location.

  • Easier for local development and website projects.

a) Same Folder


 

b) Subfolder


 

c) Parent Folder


 


3. Root-relative Path

  • Starts from the root folder of the website using /.


 


4. Current Folder (./) and Parent Folder (../)

Symbol Meaning
./ Current folder
../ Parent folder (one level up)

Example:


 


Key Points

  • Use absolute paths for external websites.

  • Use relative paths for local files and project structure.

  • Correct paths ensure that images, CSS, JS, and links load properly.

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *