HTML File Path


File Paths

It defines location of the file in website. The file may be image, web page ,style sheet or java script.

Example:-

<img src="https://codingpk.com/images/apple.jpg" alt="Apple" height="200" width="250">

Output:-

Apple

Types of File Path

  1. Absolute File Path
  2. Relative File Path

Absolute File Path:-

This specify full URL address of file.

Example:-

<img src="https://codingpk.com/images/natural.jpg" alt="Apple" height="200" width="250">

Output:-

Apple

Relative File path:-

This specify to file that is related to current page.

Example:-

<img src="/images/apple.jpg" alt="Image" style="width:300px">

This path points images folder in current folder.

Output:-

Apple Image

Different Types to Specify File Path

  • <img src="pic.jpg">

    It specify pic.jpg is located in same folder of current page.

  • <img src="images/pic.jpg">

    It specify pic.jpg is located in images folder of current folder.

  • <img src="/images/pic.jpg">

    It specify pic.jpg is located in images folder at the root of current web.

  • <img src="../pic.jpg">

    It specify pic.jpg is located in one folder up of current folder.

  • <img src="../../pic.jpg">

    It specify pic.jpg is located in two folders up of current folder.

Chapter Next »