Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Link back a folder

Nov 19, 2005 10:49PM PST

How would I go about linking back to a different subfolder?

for example think of this:

index.html
which has 2 subfolders:
folder1 (which contains file1.html)
folder2 (which contains file2.html)

so to get from index.html to file1.html it is:
<a href="folder1/file1.html">

But how would I go backwords, from file1.html to index.html? And also from file1.html to file2.html?
Thanks.

Discussion is locked

- Collapse -
It's like this....
Nov 21, 2005 8:54PM PST

First - index.html is a file and cannot have any subfolders - only a folder can have subfolders or files.

So, assuming we're talking about a directory named index, then it goes like this:


If file1 and file2 were in the same subfolder, to get from file1 to file2, the code you need in file1 is a simple <a href="file2.html">file2</a>.

But since file1 is in folder1 and file2 is in folder2 - in order to get from file1 to file2, you first need to get out of your folder1 - you do that via ../ (the dots sort of mean to go backwards, and the '/' is the directory sign. So you go back up one level with the ../ (and now you're in the index folder)then you go down nto the next folder and the file in it as in:

<a href="../subfolder2/file2.html">file2</a>

Clear as mud?

- Collapse -
and if...
Nov 22, 2005 1:46AM PST

i wanted to go back two folders it would be
<a href="../../randomfile.html>stuff</a>

right?

- Collapse -
(NT) (NT) RIGHT!!!
Nov 22, 2005 3:32AM PST
- Collapse -
(NT) (NT) great! thanks a bunch
Nov 22, 2005 3:48PM PST