HTML Basics

HTML File Paths

A file path tells the browser where to find a resource such as an image, stylesheet, or another page. Getting paths right is essential to avoid broken links.


Absolute vs Relative Paths

  • Absolute path: the complete address, e.g. https://example.com/images/logo.png.
  • Relative path: a location relative to the current file, e.g. images/logo.png.

Relative Path Examples

PathMeaning
logo.pngA file in the same folder as the current page
images/logo.pngA file inside the images subfolder
/images/logo.pngA file starting from the site root
../logo.pngA file one folder up (the parent folder)
../../logo.pngTwo folders up
Using relative paths
<!-- Same folder -->
<img src="photo.jpg" alt="Photo">

<!-- In a subfolder -->
<img src="assets/photo.jpg" alt="Photo">

<!-- One folder up -->
<img src="../photo.jpg" alt="Photo">
💡

Prefer relative paths for files within your own project so the site works no matter where it is hosted. Use absolute paths for external resources on other websites.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships