When working with CSS, I understand that I can link to another file using various methods such as:
photo.jpg
or ./photo.jpg
for a file in the same directory, and photo-folder/images/photo.jpg
or ./photo-folder/images/photo.jpg
to reference a file located below or inside the parent directory.
The same concept applies to HTML with syntax like ./[href]
or [href]
.
However, what if I need to link to a photo in a directory that is the direct or indirect parent of my current file? How can I do this without using the full drive address like
C:/Users/Username/Code/etc/photo.jpg
, when my working file is located at C:/Users/Username/Code/etc/code/file.css
...
I'm curious about how this linking process works in languages such as HTML, CSS, JS, Python (feel free to include other languages too)! :D
As a side question: Is there a technical distinction between ./file
and file
, and is it recommended to use one format over the other for reasons like preventing issues, improving readability, etc.? Personally, I haven't encountered any problems using either method, or even mixing them within the same project...