Matthieu Napoli
Matthieu Napoli

Reputation: 49623

Is it OK to use empty href on links with <base> tag

I set the base tag as such:

<base href="http://mnapoli.github.com/PHP-DI/">

Then I would like to create a link to http://mnapoli.github.com/PHP-DI/ in relative path.

I tried:

<a href="">link</a>

and it works in Chrome, but is this method standard and supposed to work on every browser?

Upvotes: 3

Views: 1698

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201728

Although href="./" as suggested in Mike’s answer is better (easier to understand to anyone who reads the code), the answer to the question posed is that using an empty URL is standard and supposed to work on all browsers. According to STD 66, a relative URL with no characters (path-empty) is allowed, and by rules on relative URLs, it is resolved as the base URL.

This has nothing to do with folders or files; URLs are strings, and whether they get mapped to folders or files on a server is at the discretion of the server.

Upvotes: 3

Mike
Mike

Reputation: 1544

I would do something like this:

<base href="http://mnapoli.github.com/PHP-DI/">

<a href="./">Home</a>

Upvotes: 3

Related Questions