Marco
Marco

Reputation: 1025

How to set a relative web path in a HTML page

I am building a website. I have many folders. The highest layer is called FOLDER1. I have two folders in FOLDER1. They are FOLDER2A, and FOLDER2B. Inside FOLDER2B, there is a html file. I need to use a picture "DOG" in FOLDER1 in that html. If I don't want to use absolute path like http://abc.com/FOLDER1/DOG.jpg as a path, how I can use a relative path like /Folder1/DOG.jpg <=== I know that this is wrong

Thanks

Upvotes: 0

Views: 110

Answers (2)

Neil Alexander
Neil Alexander

Reputation: 110

You can refer to files in the parent directory using ../, i.e. ../DOG.jpg will refer to DOG.jpg in FOLDER1 if referred to from inside FOLDER2A or FOLDER2B.

Upvotes: 1

Eric Bridger
Eric Bridger

Reputation: 3794

../DOG.jpg unless I'm missing something here. .. means up one folder. ../../ means up two, etc. To access an image in FOLDER2A from FOLDER2B ../FOLDER2A/CAT.jpg

Upvotes: 1

Related Questions