What does “./” (dot slash) refer to in terms of an HTML file path location?
I know ../ means go up a path, but what does ./ mean exactly?
I was recently going through a tutorial and it seems to be referring to just a file in the same location, so is it necessary at all? Can I just not use it if that’s all it’s doing?
./ is the the folder that the working file is in:
./ is the root directory
./ is the css folder.
This is important to remember because if you move CSS from
/css/style.css the path will change.
/ means the root of the current drive;
./ means the current directory;
../ means the parent of the current directory.
You can use the following list as quick reference:
/ = Root directory . = This location .. = Up a directory ./ = Current directory ../ = Parent of current directory ../../ = Two directories backwards
. = This location .. = Up a directory
./foo.html is just
foo.html. And it is optional, but may have relevance if a script generated the path (relevance to the script that is, not how the reference works).
./ means the current working directory. You can just reference the file directly by name, without it.
You are correct that you can omit it. It’s useful only for clarity. There is no functional difference between it being there and not being there.