Relative path vs Absolute Path?

Can someone elborate on the difference of a relative path vs an absolute path?

Relative to current/source location vs fully writing it out

1 Like

In the tutorial for a relative link I notice it’s with only one dot


I always thought it was with two dots


Do the number of dots have to do with the number of directories the link it in?

. refers to the current directory and .. refers to the parent directory
Or if you omit the dots entirely, then you’re still referring to the same host, but starting at its root directory
With two leading slashes you’re now referring to a new host, but still using the same protocol (like https)
An absolute path would start with the protocol, then the host, then the path (

1 Like


So if I were in a grandchild directory would I need three dots? … Or do the two dots apply?

No, you’d go to the parent of the parent.

Can you give me an example in HTML?

You append a slash and a directory name. Going to the parent is to add /.., add another and that’s the grandparent.
Or perhaps you’d consider the slash the end of the directory name. Kind of blurry there when it comes to the web, typically it’s not backed up by a directory structure, but a program which does… whatever it wants. There might for example not be a parent location.

don’t you mean …/
is your example in reverse? :slight_smile:

Edit: Oh and why do three dots show up whenever I try to post two dots?

There definitely needs to be slashes between directory names, but not necessarily after. It gets worse yet when the locations aren’t directories at all, but programs

For example:
the latter link adds /7, the slash is being treated as a separator, not as a terminator

For other pages you’ll find that you get redirected to an url ending in a slash. Not so in this case.

It’s up to you to decide what makes sense there. Ideally you’d automate link generation so that it is consistent.
They do mean different things, but it doesn’t translate to what’s actually happening, the difference in meaning is sometimes lost

You got me confused. :slight_smile: I counted 6.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.