In HTML, ./ is used to indicate the current directory or folder.
In <script src="./src/main.js"></script> the ./ before src indicates that the file main.js is located in the same directory as the HTML file is. It’s not necessary to put them before the file’s name.
Where .. is a reference to the folder that is above the current working directory (if the working directory is src, then ../ references myproject) and . referencing the current working directory itself (If you’re in myproject and want to access index.html you could specify it as just index.html or ./index.html). In most cases, you don’t need to specify the . explicitly.
2
Answers
In HTML,
./
is used to indicate the current directory or folder.In
<script src="./src/main.js"></script>
the./
beforesrc
indicates that the filemain.js
is located in the same directory as the HTML file is. It’s not necessary to put them before the file’s name.Tldr: It’s the current working directory and you can omit it in most cases
Lets say your folder structure looks like this:
Then it actually looks like this because of two hidden "files":
Where
..
is a reference to the folder that is above the current working directory (if the working directory issrc
, then../
referencesmyproject
) and.
referencing the current working directory itself (If you’re in myproject and want to access index.html you could specify it as justindex.html
or./index.html
). In most cases, you don’t need to specify the.
explicitly.