colourcolourcolourcolourcolourcolourcolour
Forgot my colour selection

Using The HTML “base” Element

Yeah it’s not the most widely used element; partly because it doesn’t really have much of a use except for sites that cache data like the Wayback Machine and search engine caches, like the Google cache service. In these services, the element is used in the header of the cached page to make the browser treat all relative links like they belong to the original URL. An example of it being used is typically (XHTML):

<base href="http://www.thecachedsite.com/"/>

But, you can also make it change all of the targets of links on a page. For example:

<base target="_blank"/>

..would make all of the links on the page it is put on open in a new page. This could be used in pages that have uncontrollable content, like pages which use JavaScript to write some data pulled from elsewhere for example, where you still have control of the header of the page.

Why did I post this? Well, I think it is a slightly unheard of HTML element, and one that could prove very useful if it was ever needed. The advantage of using this instead of JavaScript to achieve the same thing is that this will work where JavaScript isn’t enabled. Awesome.

Posted on May 22nd, 2008. Filed under Random, and tagged with , .

Leave a Comment

Make yourself heard

Montly Post Archives

Posts from previous months