Tag Archives: Conditional comment

HTML Tags: <base>

Overview

base

Somehow the <base> tag remains unknown to most of the web developers, but that’s quite normal. However let see what it can do. By adding the <base> tag in the head of the page you tell every link into that page how to open and a default href value. Thus if you have:

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

every link without a href attribute will open this link. That’s really useful in some cases. However the most interesting part of the base tag is the target attribute.

target=”_blank”

Everybody knows what will result from this attribute attached to a anchor tag.

<a href="http://www.stoimen.com" target="_blank">Click Here</a>

But with only adding this base tag:

<base target="_blank">

into the head … all the links will open in a new tab/window, depending on the browser preferences.

Watch out!

If you add the line above somewhere into the <body> tag the browser, will put it into the <head> which will make it difficult to track. A good practice is to place it directly into the <head>!