skip to Main Content

enter image description here

"../" – two period (e.g., src="../picture.jpg") means go up one folder.

"folder/" – (e.g., src="myfolder/picture.jpg" means go down to myfolderfolder.

But I saw this single period "./src": <script src="./src/main.js"></script> on youtube. I was wondering what it means.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. Tldr: It’s the current working directory and you can omit it in most cases

    Lets say your folder structure looks like this:

    myproject
      src
        main.js
        whatever.js
      index.html
    

    Then it actually looks like this because of two hidden "files":

    myproject
      .
      ..
      src
        .
        ..
        main.js
        whatever.js
      index.html
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search