Wow!

I’ve just found an HTML tag I never knew existed, and it’s something I’ve wished I had many times before!

The <base href=""> tag lets you set a default prefix to all links to external sources.

So for example:


<html>
    <head>
    <base href="http://www.kirupa.com">
    </head>

    <body>
    <a href="web/index.htm">PHP</a><br />
    <a href="forum">FORUM</a><br />
    </body>
</html>

The two links above would point to “http://www.kirupa.com/web/index.htm” and “http://www.kirupa.com/forum” respectively.

You can even set the base href as something like “http://mydomain.com/folder/subFolder” and then traverse back up the directory tree using “…/” in your links.

I can see how this probably sounds very dull, but I think it’s brilliant, especially as I’ve never heard of it before.

http://www.w3.org/TR/html401/struct/links.html#edef-BASE