tags:

views:

4383

answers:

5

Lets say I am currently at: http://site.com/folder/page.html

Is it possible to create a relative link on this page that points to http://site.com/folder/ without specifying anywhere "folder"? (And using only HTML)

UPDATE: As it turned out "./" works only in non-strict doctype mode, while "." works in both modes, so it is still a better answer in my opinion :) Thanks everybody.

+1  A: 

Both of the below seem to work

./

.

bdukes
This points to the root folder.
serg
Right, wasn't thinking for a sec. Thanks.
bdukes
Still not right, this goes one level up, which is not what he's asking... See Bullines answer
da5id
./ going one level up seems to be nonsense to me. why does it do that?
Johannes Schaub - litb
+6  A: 
<html>
    <head>
        <title>Page</title>
    </head>
    <body>
       <a href="./">Folder directory</a> 
    </body>
</html>
Bullines
Nope. This goes one level up. I need current folder.
serg
This is correctly linking to the current folder
MrChrister
No it is not :) The single dot is the answer.
serg
I test it in both IE and Firefox and "." was the same as "./" HTML 4.01 Transitional. Is is a doc type issue?
MrChrister
Hm, that's could be it. I am using strict, should have mentioned that probably.
serg
A: 

You can use

 ../

to mean up one level. If you have a page called page2.html in the same folder as page.html then the relative path is:

 page2.html.

If you have page2.html at the same level with folder then the path is:

  ../page2.html
Vincent Ramdhanie
+1  A: 
<a href="./">Folder</a>
Steve Tranby
+3  A: 

Just dot is working. The doctype makes a difference however as sometimes the ./ is fine as well.

<a href=".">Link to this folder</a>
MrChrister
Thanks, that's the correct one.
serg