Let's assume that I have a website with three files:/home/blog.html/home/picture1.jpg/home/files/picture2.jpgNow let's edit that blog.html file. When I want to make a link to the current folder, I'll do it this way:<a href=./>Current folder</a>But what's the right way to make a link to a file in the current folder, to a subfolder or to a file in a subfolder? It can be either:<a href=picture1.jpg>Picture 1</a><a href=files/>Files</a><a href=files/picture2.jpg>Picture 2</a>or<a href=./picture1.jpg>Picture 1</a><a href=./files/>Files</a><a href=./files/picture2.jpg>Picture 2</a>As I checked, both ways work fine in my browser. But I would like to know which of them is the preferred way? Is any of them in some detail slightly better?
Relative link to a subfolder
html;links
The part ./ is removed from the start of a URL as part of URL resolution as defined in STD 66. This has nothing to do with folders or files; it is just string manipulation dictated by generic URL specifications. Thus, for example, the URLs picture1.jpg and ./picture1.jpg have identical meaning: they resolve to the same absolute URL.Whether you prefer one to the other is a matter of taste. Other things being equal, it is best to prefer the shorter alternative, not just because of shortness but also in order to somewhat reduce the risk of confusion that people may have with meanings of relative URLs.