../ 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
Useful article: https://css-tricks.com/quick-reminder-about-file-paths/
. = 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.
A fast and small recap about paths
IF the image is not on your domain - go look there for image
image loaded using http or https protocols
(For internal use if the image is on the same server)
image in the same place as the document calling the image!
Same as above, image in the same place as the document calling the image!
Similar to Absolute Paths, just omitting the protocol and domain name
Go search my image starting from my root folder
/, than into
this time assets is in the same place as the document, so go into assets for the image
From where the document is, go one folder back
../ and go into
go two folders back, there's my image!
go two folders back
../../ and than go into
./ means the directory you're currently in.
For example css files are in folder named
CSS and html files are in folder
HTML, and both these are in folder named
XYZ means we refer css files in html as
<link rel="stylesheet" type="text/css" href="./../CSS/style.css" />
.. moves up to
. refers to the current directory
---by this logic you would just reference as:
<link rel="stylesheet" type="text/css" href="CSS/style.css" />
In reference to the quick reference list, specifically you can use the following :
\.\ Root Directory + Current directory (Drive Letter)
©2020 All rights reserved.