Let's say following is the directory structure of my website : 
Now in index.html I can simply refer images like:
<img src="./images/logo.png"> But I want to refer the same image from sub.html. What should be the src?
The root directory contains all other folders in the drive or folder, and can, of course, also contain files. You can visualize this with an upside-down tree where the roots (the root folder) are at the top and the branches (subfolders) fall below; the root is what holds together all of its lower items.
Type “echo %SYSTEMROOT%" at the command prompt and press “Enter.” The result of this search is the root folder for Microsoft Windows.
To reference a file in a subdirectory, write the directory name in front of the path, plus a forward slash, e.g. subdirectory/my-image. jpg . To link to a target file in the directory above the invoking HTML file, write two dots. So for example, if index.
../images/logo.png will move you back one folder.
../../images/logo.png will move you back two folders.
/images/logo.png will take you back to the root folder no matter where you are/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With