What do the two dots in a row (.) mean in a file path?

Asked

Viewed 981 times

11

I still don’t understand what this means. Why should I put these two points?

Example: ..\Images/Logo.png

  • 5

    Most of the time, it’s best to avoid the .. in production environment, unless your project needs to be hosted at different levels depending on the situation (if it is a separate application from the main website, relative paths help in "portability" between folders). The .. is relative to the current directory. Start with /caminho/desde/raiz, files will always be searched in the same folder.

3 answers

10

Imagine you’re in a structure like this:

/
 css
    estilo.css
 Images
    Logo.png
 Scripts
    ...

That is, at the root of the project have the css folders, Images, Scripts, etc.
If you want the.css style file to access the Logo.png file that is in another folder, the two dots in a row (..) makes the reference to the above css folder (/) and then Images.

If you use "Images/Logo.png" css, it means that the "Images" folder should be inside the current folder, which is CSS, the style.css file folder..

I hope you were able to explain.

8


Projeto
   Images
      Logo.png
   CSS
      styles.css

If you are inside the CSS folder using the file style.css and want to access an image that is in a folder at the same level of the CSS folder you do:

../Images/Logo.png

.. means come back a folder or a level.

../../ back to Project folder, or the root, depending on its structure.

  • 1

    I get it. Thank you!

7

The denotation .. moves up a folder level.

For example: Your image, Logo.png, is in the folder Images and your arquivo.css in the briefcase CSS. You use the two dots to "get" to the folder Images.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.